recorte funcionando desde el pcb

parent b3e5306e
Showing with 268 additions and 282 deletions
......@@ -181,7 +181,6 @@ public class Device extends SQLiteOpenHelper {
SQLiteDatabase db = this.getReadableDatabase();
Vector<User> users = new Vector<>();
Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null);
while (cursor.moveToNext())
if (cursor.getInt(9) == id_sup)
users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8),
......
......@@ -153,10 +153,10 @@ public class PCBDBHelper extends SQLiteOpenHelper {
Cursor cursor = db.query("collection_detail", null, "id_stu=?", new String[]{String.valueOf(id_stu)}, null, null, null, null);
Log.i(LOG_TAG, "Local recovering " + cursor.getCount() + " pictos for student " + id_stu + " from local DB");
cursor.moveToFirst();
while (cursor.moveToNext()) {
do{
Picto picto = new Picto(cursor.getInt(1), cursor.getString(2), cursor.getString(3), cursor.getString(4));
vocabulary.loadPicto(picto);
}
}while (cursor.moveToNext());
cursor.close();
db.close();
......
......@@ -131,7 +131,7 @@ public class UserLogin {
Class PictogramActivity, Class LoginActivity) {
try {
Vector<User> localUsers = PCBcontext.getDevice().findUser(email, password);
Log.i(this.getClass().getCanonicalName(), "Offline login request for supervisor "+email);
Log.i(this.getClass().getCanonicalName(), "Offline login request for supervisor "+email+localUsers.elementAt(0).get_email_sup()+localUsers.elementAt(0).is_supervisor());
if (localUsers.size() == 1) {
PCBcontext.set_user(localUsers.elementAt(0), null, null);
......
......@@ -36,7 +36,8 @@ import java.util.Vector;
public class Vocabulary implements Iterable<Picto> {
Hashtable<Integer,LinkedList<Picto>> pictos;
private static final String LOG_TAG = Vocabulary.class.getName();
Hashtable<Integer,LinkedList<Picto>> pictos;
static int DEFAULT_VOCABULARY_SIZE=200;
ImgDownloader.iImgDownloaderListener imgListener;
private ActionTalk actionTalk;
......@@ -335,7 +336,7 @@ public class Vocabulary implements Iterable<Picto> {
* @seealso com.yottacode.pictogram.dao.PCBDBHelper.getStudentVocabulary
*/
public void loadPicto(Picto picto) {
Log.i(LOG_TAG, "load picto "+picto.get_translation());
LinkedList<Picto> pictos_cat;
if (this.pictos.containsKey(picto.get_category()))
pictos_cat = pictos.get(picto.get_category());
......
......@@ -22,7 +22,6 @@ import org.json.JSONObject;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpRetryException;
import java.util.Hashtable;
import java.util.concurrent.ExecutionException;
......@@ -190,21 +189,22 @@ public class PictoUploader {
**/
public void upload(final Context context) throws IOException {
final int local_img_id = this.picto.get_id();
final boolean imgUpload_success = uploadImg(this.picto);
iPictoUploaderListener listener = new iPictoUploaderListener() {
int elements_uploaded = 0;
@Override
public void success(boolean success) {
if (success) elements_uploaded++;
else
GUITools.show_alert(context, R.string.upload_error,PictoUploader.this.picto.get_translation());
GUITools.show_alert(PCBcontext.getActivityContext(), R.string.upload_error,PictoUploader.this.picto.get_translation());
if (elements_uploaded == 2) {
PCBcontext.getPcbdb().deletePicto(local_img_id);
PictoUploader.this.picto.delete_bitmap(PCBcontext.getContext());
PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ADD, PictoUploader.this.picto));
GUITools.show_alert(context, R.string.upload_ok,PictoUploader.this.picto.get_translation());
GUITools.show_alert(PCBcontext.getContext(), R.string.upload_ok,PictoUploader.this.picto.get_translation());
}
}
};
......@@ -213,7 +213,7 @@ public class PictoUploader {
uploadTranslation(picto.get_id(), listener);
}
else {
GUITools.show_alert(context, R.string.upload_error, PictoUploader.this.picto.get_translation());
GUITools.show_alert(PCBcontext.getActivityContext(), R.string.upload_error, PictoUploader.this.picto.get_translation());
}
}
......
......@@ -64,7 +64,7 @@ public final class PCBcontext {
throw new java.lang.AssertionError("init must be called once previously ");
}
Log.i(PCBcontext.class.getCanonicalName(), "User set at student " + student.get_name_stu());
Log.i(PCBcontext.class.getCanonicalName(), "User set at student " + student.get_name_stu()+ (student.is_supervisor() ? " with supervisor "+student.get_name_sup():"."));
wrapper.setToken(token);
pcbdb = new PCBDBHelper(null, 2, student);
pcbdb.user_online(token!=null);
......
package com.yottacode.tools;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Point;
import android.util.Log;
import android.view.Display;
/**
* Created by Fernando on 01/04/2016.
......@@ -35,4 +38,10 @@ public class GUITools {
public static void show_alert(Context context, int resource_msg, String additional_msg) {
show_alert(context, resource_msg, additional_msg,null);
}
public static Point getScreenSize(Activity context){
Display display = context.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return size;
}
}
......@@ -301,6 +301,17 @@ BEGIN
END
;--
CREATE TRIGGER trg_update_supervisor
BEFORE UPDATE ON supervisor
FOR EACH ROW
WHEN NEW.id=-1
BEGIN
SELECT RAISE( ABORT,
'Null supervisor -1 is not updatable'
);
END
;--
DROP TRIGGER IF EXISTS trg_delete_collection
;--
......
......@@ -73,4 +73,9 @@
<string name="default_tts_engine">com.google.android.tts</string>
<string name="default_tts_voice_male">en-gb-x-rjs#male_1-local</string>
<string name="default_tts_voice_female">en-gb-x-fis#female_1-local</string>
<string name="crop_TextRequired">Please, introduce a message for the pictogram</string>
<string name="crop">Crop</string>
<string name="titleCropper">New pictogram</string>
<string name="uploadingImage">Uploading image</string>
</resources>
......@@ -42,6 +42,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/CIFlavorDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/CIFlavorDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/CIFlavorDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/CIFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/CIFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testCIFlavorDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testCIFlavorDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testCIFlavorDebug/assets" type="java-test-resource" />
......@@ -50,13 +57,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/testCIFlavorDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testCIFlavorDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testCIFlavorDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/CIFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/CIFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/CIFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/CIFlavor/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/CIFlavor/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/CIFlavor/assets" type="java-resource" />
......@@ -121,10 +121,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/24.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/24.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/24.2.1/jars" />
......@@ -135,17 +132,11 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/24.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/24.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
......
......@@ -12,6 +12,7 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
......@@ -52,7 +53,7 @@ import com.yottacode.pictogram.net.PictoUploader;
import com.yottacode.pictogram.net.websockets.ActionTalk;
import com.yottacode.pictogram.net.websockets.VocabularyTalk;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.cropper.EditPictoActivity;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity;
import com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity;
import com.yottacode.pictogram.tabletlibrary.gui.session.SessionActivity;
import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
......@@ -80,9 +81,6 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
private static final int CAMERA_PIC_REQUEST = 1;
private static final int GALLERY_PIC_REQUEST = 2;
private static final int MAX_WIDTH = 700;
private static final int MAX_HEIGHT = 350;
// Main layout for this activity
RelativeLayout mainLayout;
// Adapter for de grid showing the categories grid (and main pictos)
......@@ -1102,26 +1100,20 @@ protected void showOnlyTape(boolean onlyTape) {
*/
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.e(LOG_TAG,"CTSA prec (onACR)"+requestCode+" "+resultCode);
int row = getIntent().getIntExtra(Picto.JSON_ATTTRS.ROW, -1);
int col = getIntent().getIntExtra(Picto.JSON_ATTTRS.COLUMN, -1);
int freeRow = getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_ROW, -1);
int freeColumn = getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
int cat = getIntent().getIntExtra("cat", -1);
Log.i(LOG_TAG, "Picto nuevo en: " + " fila: " + row + " col: " + col + " cat: "+cat);
Bitmap imagen = null;
switch(requestCode) {
case CAMERA_PIC_REQUEST: //Captura de foto
if (data != null && resultCode==RESULT_OK) {
imagen = (Bitmap) data.getExtras().get("data");
this.launchActivity(imagen);
} else {
if(resultCode!=RESULT_OK) //Si no quieres la foto que has echado
startActivityForResult(new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE),CAMERA_PIC_REQUEST);
if(data==null) //Si te sales de la camara dandole al boton atras de android
startActivity(new Intent(this, PictogramActivity.class));
this.launchEditPictoActivity(imagen);
}
break;
case GALLERY_PIC_REQUEST: //Galeria
......@@ -1137,17 +1129,12 @@ protected void showOnlyTape(boolean onlyTape) {
cursor.close();
imagen = BitmapFactory.decodeFile(filePath);
this.launchActivity(imagen);
}else{
startActivity(new Intent(this, PictogramActivity.class));
this.launchEditPictoActivity(imagen);
}
break;
case EditPictoActivity.EDIT_PICTO_REQUEST:
Log.i(LOG_TAG, "Llega el intent de recorte->" + data.getExtras().getString(EditPictoActivity.TRANSCRIPTION));
if (resultCode == RESULT_OK) {
Log.i(LOG_TAG, "Llega el intent de recorte 2, texto: " + data.getExtras().getString(EditPictoActivity.TRANSCRIPTION));
String path = data.getExtras().getString(EditPictoActivity.PATH);
Log.i(LOG_TAG, "Path de la imagen tras llamar a gestionarlo: " + path);
String legend = data.getExtras().getString(EditPictoActivity.TRANSCRIPTION);
chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend);
}
......@@ -1164,8 +1151,7 @@ protected void showOnlyTape(boolean onlyTape) {
// Set up the buttons
int cat = category != -1 ? category : Picto.NO_CATEGORY;
Log.i("DETALLES","Path de la imagen: "+ selectedImagePath);
Log.e(LOG_TAG,"CTSA 1");
PCBcontext.getVocabulary().saveLocalPicto(
selectedImagePath,
legend,
......@@ -1177,6 +1163,7 @@ protected void showOnlyTape(boolean onlyTape) {
new iLocalPicto() {
@Override
public void saved(Picto localPicto) {
Log.e(LOG_TAG,"CTSA 2");
refresh();
try {
if (PCBcontext.is_user_online())
......@@ -1191,28 +1178,21 @@ protected void showOnlyTape(boolean onlyTape) {
/**Para cambiar la activity de PictogramActivity a EditPictoActivity
* @param image
*/
public void launchActivity(Bitmap image){
public void launchEditPictoActivity(Bitmap image){
Intent intent = new Intent(this, EditPictoActivity.class);
if(image!=null) {
float aspectFactor = 1;
Point size=GUITools.getScreenSize(this);
float bWidth = image.getWidth();
float bHeight = image.getHeight();
//Reducir la imagen a la mitad de su aspect ratio que viene de galería(Suele ser mayor que el tamaño maximo)
if(bWidth>MAX_WIDTH || bHeight>MAX_HEIGHT){
image = Bitmap.createScaledBitmap(image,(int) bWidth/2,(int) bHeight/2,true);
bWidth = image.getWidth();
bHeight = image.getHeight();
}
//Ir ampliando el alto y ancho hasta lo máximo posible (sin perder el ratio original), sin pasarse de los límites
while(bWidth < MAX_WIDTH && bHeight<MAX_HEIGHT){
bWidth = bWidth * aspectFactor;
bHeight = bHeight * aspectFactor;
aspectFactor += 0.1;
}
float factorX=size.x*0.7f/bWidth;
float factorY=size.y*0.7f/bHeight;
float factor= factorY>factorX ? factorX : factorY;
Log.i(LOG_TAG,"Reescalando tamaño máximo de "+size.x+" "+bWidth+"-->"+bWidth*factor);
Log.i(LOG_TAG,"Reescalando tamaño máximo de "+size.y+" "+bHeight+"-->"+bHeight*factor);
bWidth=bWidth*factor;
bHeight=bHeight*factor;
Bitmap rescaled = Bitmap.createScaledBitmap(image,(int) bWidth, (int) bHeight, true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
......
package com.yottacode.pictogram.tabletlibrary.cropper;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper;
import android.content.Context;
import android.content.res.Resources;
......@@ -15,18 +15,15 @@ import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle.Handle;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil;
import com.yottacode.pictogram.tabletlibrary.cropper.util.HandleUtil;
import com.yottacode.pictogram.tabletlibrary.cropper.util.PaintUtil;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle.Handle;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.HandleUtil;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.PaintUtil;
/**
......@@ -36,12 +33,7 @@ import com.yottacode.pictogram.tabletlibrary.cropper.util.PaintUtil;
*/
public class CropImageView extends ImageView {
// Private Constants ///////////////////////////////////////////////////////////////////////////
private static final int CAMERA_PIC_REQUEST = 1;
private static final int GALLERY_PIC_REQUEST = 2;
private static final int VERTICAL_ORIENTATION = 200;
private static final int HORIZONTAL_ORIENTATION = 300;
@SuppressWarnings("unused")
private static final String TAG = CropImageView.class.getName();
......
package com.yottacode.pictogram.tabletlibrary.cropper;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.PCBcontext;
......@@ -31,6 +37,7 @@ public class EditPictoActivity extends Activity {
public static final String TRANSCRIPTION = "textPicto";
public static final String PATH = "pathImage";
public static final String IMAGE_PICTO = "imagePicto";
private static final String LOG_PATH = EditPictoActivity.class.getName();
// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
......@@ -42,57 +49,63 @@ public class EditPictoActivity extends Activity {
// Initialize Views.
final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
final EditText legend = (EditText) findViewById(R.id.legend);
final Button okButton = (Button) findViewById(R.id.okButton);
final Button cancelButton = (Button) findViewById(R.id.cancelButton);
final EditText legend = (EditText) findViewById(R.id.edtLegend);
final ImageButton okButton = (ImageButton) findViewById(R.id.okButton);
final ImageButton cancelButton = (ImageButton) findViewById(R.id.cancelButton);
cropImageView.setFixedAspectRatio(true);
cropImageView.setGuidelines(2);
cropImageView.setAspectRatio(1,1);
//Obtener leyenda
String legendText = getIntent().getExtras().getString(EditPictoActivity.TRANSCRIPTION);
if(legendText != null) { //Si tenia leyenda(editarlo)
legend.setText(legendText);
}else{ //Si no tenia el picto leyenda
legend.setTextColor(Color.GRAY);
legend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
legend.setText("");
legend.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ((actionId== EditorInfo.IME_ACTION_DONE ) )
{
//Toast.makeText(getActivity(), "call",45).show();
// hide virtual keyboard
InputMethodManager imm = (InputMethodManager)EditPictoActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
okButton.setImageAlpha(legend.getText().toString().trim().length()>0 ? 255 : 30);
return true;
}
});
}
return false;
}
});
//Obtener imagen del intent
byte[] byteArray = getIntent().getByteArrayExtra(EditPictoActivity.IMAGE_PICTO);
Bitmap imagePicto = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
cropImageView.setImageBitmap(imagePicto);
cropImageView.setMaxWidth(imagePicto.getWidth());
cropImageView.setMaxHeight(imagePicto.getHeight());
//Gestion de botones
okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Bitmap croppedImage = cropImageView.getCroppedImage();
//Escalar imagen
Bitmap finalImage = croppedImage.createScaledBitmap(croppedImage,96,96,true);
//Guardar imagen en galeria y obtener la ruta
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
finalImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(PCBcontext.getContext().getContentResolver(), finalImage, legend.getText()+"-recorte", null);
Uri pathImage = Uri.parse(path);
Intent intent = getIntent(); //Mandar a pictogram activity el path y el texto de la imagen
intent.putExtra(PATH,pathImage.toString());
intent.putExtra(TRANSCRIPTION,legend.getText().toString());
cropImageView.setImageBitmap(finalImage);
setResult(RESULT_OK,intent);
finish(); //Termina la actividad de editar
if (legend.getText().toString().trim().length()>0) {
final Bitmap croppedImage = cropImageView.getCroppedImage();
//Escalar imagen
Bitmap finalImage = croppedImage.createScaledBitmap(croppedImage, 96, 96, true);
//Guardar imagen en galeria y obtener la ruta
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
finalImage.compress(Bitmap.CompressFormat.JPEG, 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);
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(TRANSCRIPTION, legend.getText().toString());
cropImageView.setImageBitmap(finalImage);
setResult(RESULT_OK, intent);
finish(); //Termina la actividad de editar
}
else Toast.makeText(getBaseContext(),R.string.crop_TextRequired, Toast.LENGTH_LONG).show();
}
});
......@@ -100,37 +113,25 @@ public class EditPictoActivity extends Activity {
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setResult(RESULT_CANCELED,getIntent());
finish();
setResult(RESULT_CANCELED,getIntent());
}
});
}
/**
* To set background image for simulate the pictogramActivity
* @param bm
*/
/*public void setBackgroundImage(Bitmap bm){
ImageView backgroundImage = (ImageView) findViewById(R.id.backgroundImage);
backgroundImage.setImageBitmap(bm);
}*/
/**
* To set the image to crop
* @param bm
*/
public void setCropImage(Bitmap bm){
ImageView cropImage = (ImageView) findViewById(R.id.CropImageView);
cropImage.setImageBitmap(bm);
}
/**
* To set the image to crop
* @param text
*/
public void setLegendImage(String text){
EditText legend = (EditText) findViewById(R.id.legend);
legend.setText(text.toString());
public String getRealPathFromURI(Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = this.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
}
......@@ -11,12 +11,12 @@
* governing permissions and limitations under the License.
*/
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
/**
* Enum representing an edge in the crop window.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge;
/**
* Simple class to hold a pair of Edges.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
/**
* HandleHelper class to handle the center handle.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.EdgePair;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.EdgePair;
/**
* HandleHelper class to handle corner Handles (i.e. top-left, top-right, bottom-left, and
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
/**
* Enum representing a pressable, draggable Handle on the crop window.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.EdgePair;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.EdgePair;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
/**
* Abstract helper class to handle operations on a crop window Handle.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
/**
* Handle helper class to handle horizontal handles (i.e. top and bottom handles).
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
/**
* HandleHelper class to handle vertical handles (i.e. left and right handles).
......
package com.yottacode.pictogram.tabletlibrary.cropper.util;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util;
import android.graphics.RectF;
import android.support.annotation.NonNull;
......
package com.yottacode.pictogram.tabletlibrary.cropper.util;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util;
import android.graphics.PointF;
import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle.Handle;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle.Handle;
/**
* Utility class to perform basic operations with Handles.
......
package com.yottacode.pictogram.tabletlibrary.cropper.util;
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util;
import android.content.res.Resources;
import android.graphics.Paint;
......
......@@ -22,109 +22,99 @@
android:id="@+id/backgroundImage"
app:srcCompat="@color/black_translucent" />-->
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:orientation="vertical"
android:id="@+id/TotalLayout"
android:background="@color/black_translucent">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:paddingTop="@dimen/content_padding"
android:id="@+id/crop_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/titleCropper"
android:textSize="24sp"
android:textStyle="bold"
android:textColor="@android:color/white"
android:layout_weight="1"
android:layout_gravity="top"
android:textColor="@android:color/holo_blue_light"
android:textAlignment="center"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_alignStart="@+id/linearLayout2"
android:layout_centerVertical="false"
android:layout_centerHorizontal="true" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="false"
android:layout_centerHorizontal="true">
android:layout_gravity="center_horizontal"
/>
<com.yottacode.pictogram.tabletlibrary.cropper.CropImageView
<GridLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/crop_legend"
android:layout_gravity="center_horizontal"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding"
>
<com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.CropImageView
android:id="@+id/CropImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:layout_below="@+id/title"
android:layout_alignParentStart="true"
android:layout_gravity="center_horizontal"
android:maxHeight="350px"
android:maxWidth="700px" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="@string/legendText"
android:ems="10"
android:id="@+id/legend"
android:textAlignment="center"
android:textColor="@android:color/white"
android:layout_above="@+id/linearLayout"
android:layout_centerHorizontal="true"
android:gravity="center_vertical|center_horizontal"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="13dp">
<Button
android:id="@+id/okButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="120dp"
android:text="@string/accept"
android:cropToPadding="false"
android:layout_row="1"
android:layout_column="1"
android:layout_columnSpan="2"
/>
<TextView
android:layout_gravity="right"
android:textColor="#33B5E5"
android:textSize="20sp"
android:textAlignment="center"
android:layout_alignParentBottom="true"
android:layout_toStartOf="@+id/cancelButton"
android:width="70dp"
android:layout_marginRight="10dp" />
android:text="@string/legendText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textLegend"
android:layout_row="2"
android:layout_column="1"
/>
<Button
android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="120dp"
android:text="@string/cancel"
android:textColor="#33B5E5"
android:textSize="20sp"
android:textAlignment="center"
android:layout_alignBaseline="@+id/okButton"
android:layout_alignBottom="@+id/okButton"
android:layout_toEndOf="@+id/CropImageView"
android:width="70dp"
android:layout_marginLeft="10dp" />
</LinearLayout>
<EditText
android:layout_gravity="center_horizontal"
android:textSize="20sp"
android:imeOptions="actionDone"
android:inputType="textImeMultiLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:id="@+id/edtLegend"
android:textColor="@android:color/white"
android:layout_row="2"
android:layout_column="2"
/>
<ImageButton
android:id="@+id/okButton"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:background="@drawable/session_ok"
android:clickable="false"
android:layout_row="1"
android:layout_column="3"
android:elevation="1dp" />
<ImageButton
android:id="@+id/cancelButton"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/session_fail"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
android:layout_row="1"
android:layout_column="3"/>
</RelativeLayout>
</GridLayout>
</LinearLayout>
<!--</FrameLayout>-->
......@@ -5,7 +5,7 @@
<!---session-->
<string name="session_method">Método</string>
<string name="session_insrtuction">Instrucción</string>
<string name="session_instruction">Instrucción</string>
<string name="session_header">Seleccion de método e instrucción</string>
<string name="session_error">Error de conexión</string>
<string name="session_noinstructions">Alumno sin ninguna instrucción asignada. Por favor, asigne al menos una instrucción al alumno desde Pictogram Web</string>
......@@ -35,13 +35,12 @@
<string name="session_eval_notevuated">no evaluado</string>
<string name="session_eval_discarded">inválido</string>
<string name="crop">Recortar</string>
<string name="titleCropper">Editar Picto</string>
<string name="croppedImageDesc">Vista Previa</string>
<string name="cancel">Cancelar</string>
<string name="accept">Aceptar</string>
<string name="legendText">Leyenda</string>
<string name="titleCropper">Nuevo Pictograma</string>
<string name="crop_TextRequired">Por favor, introduzca una leyenda para el pictograma</string>
<string name="legendText">Leyenda:</string>
<string name="dialogCamera">Hacer Foto</string>
<string name="dialogGallery">Seleccionar de Galería</string>
<string name="dialogTitle">Seleccionar Método</string>
<string name="dialogCancel">Cancelar</string>
<string name="uploadingImage">Subiendo imagen al servidor</string>
</resources>
......@@ -44,15 +44,16 @@
<string name="dialogGallery">Seleccionar de Galería</string>
<string name="dialogCancel">Cancelar</string>
<!-- Cropper -->
<string name="legendText">Leyenda</string>
<string name="titleCropper">Editar Picto</string>
<string name="legendText">Leyenda:</string>
<string name="fixedAspectRatio">fixedAspectRatio =\u0020</string>
<string name="aspectRatioXHeader">aspectRatioX =\u0020</string>
<string name="aspectRatioYHeader">aspectRatioY =\u0020</string>
<string name="showGuidelines">showGuidelines =\u0020</string>
<string name="accept">Aceptar</string>
<string name="cancel">Cancel</string>
<string name="croppedImageDesc">Vista Previa</string>
<string name="crop">Recortar</string>
<string name="titleCropper">Nuevo Pictograma</string>
<string name="crop_TextRequired">Por favor, introduzca una leyenda para el pictograma</string>
<string name="uploadingImage">Subiendo imagen al servidor</string>
<string-array name="showGuidelinesArray">
<item>Off</item>
......
......@@ -74,7 +74,7 @@
android:screenOrientation="landscape" />
<activity
android:name="com.yottacode.pictogram.tabletlibrary.cropper.EditPictoActivity"
android:name="com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleInstance"
......
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