Commit 108bffc6 by Jose Antonio

Merged branch develop into develop

parents f809bc90 dd79da49
Showing with 725 additions and 479 deletions
...@@ -11,7 +11,7 @@ android { ...@@ -11,7 +11,7 @@ android {
versionName "1.0" versionName "1.0"
resValue "string", "db_name", "PCB.db" resValue "string", "db_name", "PCB.db"
resValue "integer", "db_version", "2" resValue "integer", "db_version", "2"
resValue "string", "app_version", "0.0" resValue "string", "app_version", "0.1"
resValue "string", "core_vocabulary", "core_vocabulary" resValue "string", "core_vocabulary", "core_vocabulary"
resValue "string", "apk", "to_be_set_in_subproject" resValue "string", "apk", "to_be_set_in_subproject"
} }
......
...@@ -209,7 +209,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -209,7 +209,7 @@ public class Vocabulary implements Iterable<Picto> {
@Override @Override
public void error(RestapiWrapper.HTTPException e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getName(), " Server RESTAPI error: " + e.getLocalizedMessage()); Log.e(this.getClass().getName(), " Server RESTAPI error: " + e.getLocalizedMessage());
Vocabulary.this.imgListener.error(e); if (Vocabulary.this.imgListener!=null) Vocabulary.this.imgListener.error(e);
} }
}); });
......
...@@ -66,14 +66,6 @@ ...@@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/assets" type="java-test-resource" />
...@@ -82,6 +74,14 @@ ...@@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......
...@@ -250,9 +250,6 @@ public class CropImageView extends ImageView { ...@@ -250,9 +250,6 @@ public class CropImageView extends ImageView {
* @return a new Bitmap representing the cropped image * @return a new Bitmap representing the cropped image
*/ */
public Bitmap getCroppedImage() { public Bitmap getCroppedImage() {
// Implementation reference: http://stackoverflow.com/a/26930938/1068656
final Drawable drawable = this.getDrawable(); final Drawable drawable = this.getDrawable();
if (drawable == null || !(drawable instanceof BitmapDrawable)) { if (drawable == null || !(drawable instanceof BitmapDrawable)) {
return null; return null;
...@@ -271,15 +268,15 @@ public class CropImageView extends ImageView { ...@@ -271,15 +268,15 @@ public class CropImageView extends ImageView {
final float transY = matrixValues[Matrix.MTRANS_Y]; final float transY = matrixValues[Matrix.MTRANS_Y];
final Bitmap originalBitmap = ((BitmapDrawable) drawable).getBitmap(); final Bitmap originalBitmap = ((BitmapDrawable) drawable).getBitmap();
Log.i("DETALLES","ScaleX: "+scaleX + "- ScaleY: "+scaleY); /*Log.i("DETALLES","ScaleX: "+scaleX + "- ScaleY: "+scaleY);
Log.i("DETALLES","transX: "+transX + "- transY: "+transY); Log.i("DETALLES","transX: "+transX + "- transY: "+transY);
Log.i("DETALLES","Edge Left: "+Edge.LEFT.getCoordinate() + "- Edge Top: "+Edge.TOP.getCoordinate()); Log.i("DETALLES","Edge Left: "+Edge.LEFT.getCoordinate() + "- Edge Top: "+Edge.TOP.getCoordinate());
Log.i("DETALLES","ancho original: "+originalBitmap.getWidth() + " Alto original: "+originalBitmap.getHeight()); Log.i("DETALLES","ancho original: "+originalBitmap.getWidth() + " Alto original: "+originalBitmap.getHeight());
final float cropWidth = Edge.getWidth(); final float cropWidth = Edge.getWidth();
final float cropHeight = Edge.getHeight(); final float cropHeight = Edge.getHeight();*/
Log.i("DETALLES","ancho original: "+originalBitmap.getWidth() + " Alto original: "+originalBitmap.getHeight()); /*Log.i("DETALLES","ancho original: "+originalBitmap.getWidth() + " Alto original: "+originalBitmap.getHeight());
Log.i("DETALLES","ancho: "+cropWidth + " Alto: "+cropHeight); Log.i("DETALLES","ancho: "+cropWidth + " Alto: "+cropHeight);*/
// Ensure that the left and top edges are not outside of the ImageView bounds. // Ensure that the left and top edges are not outside of the ImageView bounds.
/*final float bitmapLeft = (transX < 0) ? Math.abs(transX) : 0; /*final float bitmapLeft = (transX < 0) ? Math.abs(transX) : 0;
final float bitmapTop = (transY < 0) ? Math.abs(transY) : 0;*/ final float bitmapTop = (transY < 0) ? Math.abs(transY) : 0;*/
...@@ -287,17 +284,17 @@ public class CropImageView extends ImageView { ...@@ -287,17 +284,17 @@ public class CropImageView extends ImageView {
// Get the original bitmap object. // Get the original bitmap object.
//final Bitmap originalBitmap = ((BitmapDrawable) drawable).getBitmap(); //final Bitmap originalBitmap = ((BitmapDrawable) drawable).getBitmap();
final float bitmapLeft = ((findViewById(R.id.ScrollView)).getWidth() - originalBitmap.getWidth())/2; /*final float bitmapLeft = ((findViewById(R.id.ScrollView)).getWidth() - originalBitmap.getWidth())/2;
final float bitmapTop = ((findViewById(R.id.ScrollView)).getHeight() - originalBitmap.getHeight())/2; final float bitmapTop = ((findViewById(R.id.ScrollView)).getHeight() - originalBitmap.getHeight())/2;*/
Log.i("DETALLES","bitmapLeft: "+bitmapLeft + "- bitmapTop: "+bitmapTop); /* Log.i("DETALLES","bitmapLeft: "+bitmapLeft + "- bitmapTop: "+bitmapTop);
// Calculate the top-left corner of the crop window relative to the ~original~ bitmap size. // Calculate the top-left corner of the crop window relative to the ~original~ bitmap size.
final float cropX = (bitmapLeft + Edge.LEFT.getCoordinate()); final float cropX = (bitmapLeft + Edge.LEFT.getCoordinate());
final float cropY = (bitmapTop + Edge.TOP.getCoordinate()); final float cropY = (bitmapTop + Edge.TOP.getCoordinate());
Log.i("DETALLES","Edge Left: "+Edge.LEFT.getCoordinate() + "- Edge Top: "+Edge.TOP.getCoordinate()); Log.i("DETALLES","Edge Left: "+Edge.LEFT.getCoordinate() + "- Edge Top: "+Edge.TOP.getCoordinate());
Log.i("DETALLES","Posicion X: "+cropX + "- Posicion Y: "+cropY); Log.i("DETALLES","Posicion X: "+cropX + "- Posicion Y: "+cropY);*/
// Calculate the crop window size relative to the ~original~ bitmap size. // Calculate the crop window size relative to the ~original~ bitmap size.
// Make sure the right and bottom edges are not outside the ImageView bounds (this is just to address rounding discrepancies). // Make sure the right and bottom edges are not outside the ImageView bounds (this is just to address rounding discrepancies).
...@@ -308,10 +305,10 @@ public class CropImageView extends ImageView { ...@@ -308,10 +305,10 @@ public class CropImageView extends ImageView {
Log.i("DETALLES","ancho: "+cropWidth + " Alto: "+cropHeight);*/ Log.i("DETALLES","ancho: "+cropWidth + " Alto: "+cropHeight);*/
// Crop the subset from the original Bitmap. // Crop the subset from the original Bitmap.
return Bitmap.createBitmap(originalBitmap, return Bitmap.createBitmap(originalBitmap,
(int) cropX, (int) (Edge.LEFT.getCoordinate() - transX),
(int) cropY, (int) (Edge.TOP.getCoordinate() - transY),
(int) cropWidth, (int) Edge.getWidth(),
(int) cropHeight); (int) Edge.getHeight());
} }
...@@ -573,4 +570,7 @@ public class CropImageView extends ImageView { ...@@ -573,4 +570,7 @@ public class CropImageView extends ImageView {
invalidate(); invalidate();
} }
public void setGravity(int gravity) {
this.setGravity(gravity);
}
} }
package com.yottacode.pictogram.tabletlibrary.cropper;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import com.yottacode.pictogram.tabletlibrary.R;
/**
* Created by German on 06/02/2017.
*/
public class EditPictoActivity extends Activity {
// Private Constants ///////////////////////////////////////////////////////////////////////////
public static final int EDIT_PICTO_REQUEST = 2288;
public static final String TRANSCRIPTION = "textPicto";
public static final String IMAGE_PICTO = "imagePicto";
// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.edit_picto_layout);
// 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 ImageView backgroundImage = (ImageView) findViewById(R.id.backgroundImage);
cropImageView.setFixedAspectRatio(true);
cropImageView.setGuidelines(2);
cropImageView.setAspectRatio(1,1);
String legendText = getIntent().getExtras().getString(EditPictoActivity.TRANSCRIPTION);
if(legendText != null) {
Log.i("DETALLES","Llega el intent al layout recortar, con texto: " + legendText);
legend.setText(legendText);
}else{
legend.setTextColor(Color.GRAY);
legend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
legend.setText("");
}
});
}
byte[] byteArray = getIntent().getByteArrayExtra(EditPictoActivity.IMAGE_PICTO);
Bitmap imagePicto = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
cropImageView.setImageBitmap(imagePicto);
/*byteArray = getIntent().getByteArrayExtra("imageBackground");
Bitmap imageBackground = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
backgroundImage.setImageBitmap(imageBackground);*/
okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Bitmap croppedImage = cropImageView.getCroppedImage();
//Escalar y guardarla al server
croppedImage.createScaledBitmap(croppedImage,96,96,true);
Intent intent = getIntent();
intent.putExtra(EditPictoActivity.TRANSCRIPTION,legend.getText().toString());
Log.i("DETALLES","sale el intent al layout recortar, con texto: " + legend.getText().toString());
cropImageView.setImageBitmap(croppedImage);
setResult(RESULT_OK,intent);
finish();
}
});
//Si cancela, volver a pictogram activity
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
/**
* 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());
}
}
package com.yottacode.pictogram.tabletlibrary.cropper;
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.ToggleButton;
import com.yottacode.pictogram.tabletlibrary.cropper.CropImageView;
import com.yottacode.pictogram.tabletlibrary.R;
public class MainCropImage extends Activity {
// Private Constants ///////////////////////////////////////////////////////////////////////////
private static final int GUIDELINES_ON_TOUCH = 1;
// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.crop_layout);
// Initialize Views.
//final ToggleButton fixedAspectRatioToggleButton = (ToggleButton) findViewById(R.id.fixedAspectRatioToggle);
//final TextView aspectRatioXTextView = (TextView) findViewById(R.id.aspectRatioX);
//final SeekBar aspectRatioXSeekBar = (SeekBar) findViewById(R.id.aspectRatioXSeek);
//final TextView aspectRatioYTextView = (TextView) findViewById(R.id.aspectRatioY);
//final SeekBar aspectRatioYSeekBar = (SeekBar) findViewById(R.id.aspectRatioYSeek);
//final Spinner guidelinesSpinner = (Spinner) findViewById(R.id.showGuidelinesSpin);
final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
final ImageView croppedImageView = (ImageView) findViewById(R.id.croppedImageView);
final Button cropButton = (Button) findViewById(R.id.Button_crop);
cropImageView.setGuidelines(CropImageView.GUIDELINES_ON); //To show the guidelines
cropImageView.setAspectRatio(1,1);
// Initializes fixedAspectRatio toggle button.
/*fixedAspectRatioToggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cropImageView.setFixedAspectRatio(isChecked);
cropImageView.setAspectRatio(aspectRatioXSeekBar.getProgress(), aspectRatioYSeekBar.getProgress());
aspectRatioXSeekBar.setEnabled(isChecked);
aspectRatioYSeekBar.setEnabled(isChecked);
}
});*/
// Set seek bars to be disabled until toggle button is checked.
/*aspectRatioXSeekBar.setEnabled(false);
aspectRatioYSeekBar.setEnabled(false);
aspectRatioXTextView.setText(String.valueOf(aspectRatioXSeekBar.getProgress()));
aspectRatioYTextView.setText(String.valueOf(aspectRatioXSeekBar.getProgress()));*/
// Initialize aspect ratio X SeekBar.
/*aspectRatioXSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar aspectRatioXSeekBar, int progress, boolean fromUser) {
if (progress < 1) {
aspectRatioXSeekBar.setProgress(1);
}
cropImageView.setAspectRatio(aspectRatioXSeekBar.getProgress(), aspectRatioYSeekBar.getProgress());
aspectRatioXTextView.setText(String.valueOf(aspectRatioXSeekBar.getProgress()));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing.
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing.
}
});*/
// Initialize aspect ratio Y SeekBar.
/*aspectRatioYSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar aspectRatioYSeekBar, int progress, boolean fromUser) {
if (progress < 1) {
aspectRatioYSeekBar.setProgress(1);
}
cropImageView.setAspectRatio(aspectRatioXSeekBar.getProgress(), aspectRatioYSeekBar.getProgress());
aspectRatioYTextView.setText(String.valueOf(aspectRatioYSeekBar.getProgress()));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing.
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing.
}
});*/
// Set up the Guidelines Spinner.
/*guidelinesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
cropImageView.setGuidelines(i);
}
public void onNothingSelected(AdapterView<?> adapterView) {
// Do nothing.
}
});
guidelinesSpinner.setSelection(GUIDELINES_ON_TOUCH);*/
// Initialize the Crop button.
cropButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Bitmap croppedImage = cropImageView.getCroppedImage();
croppedImageView.setImageBitmap(croppedImage);
}
});
}
}
...@@ -29,7 +29,7 @@ import java.util.ArrayList; ...@@ -29,7 +29,7 @@ import java.util.ArrayList;
public class PictoItemViewGenerator { public class PictoItemViewGenerator {
public static final int LAYOUT = R.layout.picto_grid_item; public static final int LAYOUT = R.layout.picto_grid_item;
public static final int LAYOUT_BIG = R.layout.picto_grid_item_big; public static final int LAYOUT_BIG = R.layout.picto_grid_item_big;
private static final byte MAX_LINE_LENGTH = 9; private static final byte MAX_LINE_LENGTH = 12;
private static final byte MAX_LINE_LENGTH_FULL = 7; private static final byte MAX_LINE_LENGTH_FULL = 7;
private static final String LOG_TAG = PictoItemViewGenerator.class.getCanonicalName(); private static final String LOG_TAG = PictoItemViewGenerator.class.getCanonicalName();
public static int mirror_color=0; public static int mirror_color=0;
...@@ -40,8 +40,11 @@ public class PictoItemViewGenerator { ...@@ -40,8 +40,11 @@ public class PictoItemViewGenerator {
* @param picto Pictogram to set the legend text * @param picto Pictogram to set the legend text
* @return the text modified * @return the text modified
*/ */
private static String format_legend(Picto picto, int maxlength) { private static String format_legend(Picto picto, int maxlength,boolean isFull) {
String texto=picto.get_translation().toUpperCase(); String texto=picto.get_translation().toUpperCase();
if(!isFull) return texto;
WordTools wordTools=new WordTools(); WordTools wordTools=new WordTools();
if (texto.length()>maxlength) { if (texto.length()>maxlength) {
String[] words = texto.split(" "); String[] words = texto.split(" ");
...@@ -73,7 +76,7 @@ public class PictoItemViewGenerator { ...@@ -73,7 +76,7 @@ public class PictoItemViewGenerator {
int width = bitmap.getWidth(); //Ancho original int width = bitmap.getWidth(); //Ancho original
int height = bitmap.getHeight(); //Alto original int height = bitmap.getHeight(); //Alto original
String texto = format_legend(picto,MAX_LINE_LENGTH); //String texto = format_legend(picto,MAX_LINE_LENGTH);
/*if(picto.get_legend().equals("normal")) { //Normal legend /*if(picto.get_legend().equals("normal")) { //Normal legend
android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig(); android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
...@@ -126,7 +129,7 @@ public class PictoItemViewGenerator { ...@@ -126,7 +129,7 @@ public class PictoItemViewGenerator {
textView.setWidth(100); textView.setWidth(100);
textView.setGravity(Gravity.CENTER); textView.setGravity(Gravity.CENTER);
textView.setMaxLines(3); textView.setMaxLines(3);
textView.setText(texto); //textView.setText(texto);
textView.setDrawingCacheEnabled(true); textView.setDrawingCacheEnabled(true);
canvas.drawBitmap(textView.getDrawingCache(), 0, 25, null); canvas.drawBitmap(textView.getDrawingCache(), 0, 25, null);
...@@ -169,64 +172,66 @@ public class PictoItemViewGenerator { ...@@ -169,64 +172,66 @@ public class PictoItemViewGenerator {
.getColor(R.color.picto_default_background)); .getColor(R.color.picto_default_background));
redCrossImage.setVisibility(View.GONE); redCrossImage.setVisibility(View.GONE);
layoutWrapper.setVisibility(View.GONE);
pictoImage.setVisibility(View.GONE);
legend.setVisibility(View.GONE);
legend_full.setVisibility(View.GONE);
pictoImage.setImageBitmap(null);
layoutWrapper.setAlpha(1f);
if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor() && picto!=null) { if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor() || (picto!=null && !picto.is_invisible())) {
layoutWrapper.setVisibility(View.VISIBLE); layoutWrapper.setVisibility(View.VISIBLE);
pictoImage.setVisibility(View.VISIBLE); pictoImage.setVisibility(View.VISIBLE);
layoutWrapper.setBackground(convertView.getResources() layoutWrapper.setBackground(convertView.getResources()
.getDrawable(R.drawable.picto_grid_item_border)); .getDrawable(R.drawable.picto_grid_item_border));
} else if (picto == null || picto.is_invisible() ) {
layoutWrapper.setVisibility(View.GONE);
pictoImage.setVisibility(View.GONE);
legend.setVisibility(View.GONE);
legend_full.setVisibility(View.GONE);
}
if( picto!=null) { if (picto!=null) {
layoutWrapper.setAlpha(!picto.is_invisible() ? 1.00f : PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? 0.25f : 0f ); layoutWrapper.setAlpha(!picto.is_invisible() ? 1.00f : PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? 0.25f : 0f);
try { try {
Bitmap bm = picto.get_bitmap(PCBcontext.getContext()); Bitmap bm = picto.get_bitmap(PCBcontext.getContext());
switch (picto.get_legend()) { switch (picto.get_legend()) {
case "none": case "none":
legend.setVisibility(View.GONE); legend.setVisibility(View.GONE);
legend_full.setVisibility(View.GONE); legend_full.setVisibility(View.GONE);
break; break;
case "normal": case "normal":
legend.setText(format_legend(picto,MAX_LINE_LENGTH)); legend.setText(format_legend(picto, MAX_LINE_LENGTH, false));
legend.setVisibility(View.VISIBLE); legend.setVisibility(View.VISIBLE);
legend_full.setVisibility(View.GONE); legend_full.setVisibility(View.GONE);
break; break;
default: default:
legend_full.setText(format_legend(picto,MAX_LINE_LENGTH_FULL)); legend_full.setText(format_legend(picto, MAX_LINE_LENGTH_FULL, true));
legend.setVisibility(View.GONE); legend.setVisibility(View.GONE);
legend_full.setVisibility(View.VISIBLE); legend_full.setVisibility(View.VISIBLE);
}
pictoImage.setImageBitmap(bm);
if (picto.is_magnify()) {
pictoImage.setScaleX(1.2f);
pictoImage.setScaleY(1.2f);
}
if (picto.is_disabled())
redCrossImage.setVisibility(View.VISIBLE);
if (picto.is_category())
layout.setBackgroundColor(picto.get_color());
if (picto.is_mirror() && !preventMirror) {
int color[] = {Color.WHITE, Color.LTGRAY, Color.GRAY, Color.DKGRAY, Color.BLACK, Color.DKGRAY, Color.GRAY, Color.LTGRAY, Color.WHITE};
float scale[] = {1f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.4f, 1.3f, 1.2f, 1.1f};
mirror_color++;
pictoImage.setScaleX(scale[mirror_color % scale.length]);
pictoImage.setScaleY(scale[mirror_color % scale.length]);
if (picto.is_highlight_background())
layout.setBackgroundColor(color[mirror_color % color.length]);
}
} catch (IOException e) {
e.printStackTrace();
} }
pictoImage.setImageBitmap(bm);
if (picto.is_magnify()) {
pictoImage.setScaleX(1.2f);
pictoImage.setScaleY(1.2f);
}
if (picto.is_disabled())
redCrossImage.setVisibility(View.VISIBLE);
if (picto.is_category())
layout.setBackgroundColor(picto.get_color());
if (picto.is_mirror() && !preventMirror) {
int color[]={Color.WHITE,Color.LTGRAY,Color.GRAY,Color.DKGRAY,Color.BLACK,Color.DKGRAY,Color.GRAY,Color.LTGRAY,Color.WHITE};
float scale[]={1f,1.1f,1.2f,1.3f,1.4f,1.5f,1.4f,1.3f,1.2f,1.1f};
mirror_color++;
pictoImage.setScaleX(scale[mirror_color%scale.length]);
pictoImage.setScaleY(scale[mirror_color%scale.length]);
if (picto.is_highlight_background()) layout.setBackgroundColor(color[mirror_color%color.length]);
}
} catch (IOException e) {
e.printStackTrace();
} }
} }
......
...@@ -2,39 +2,34 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator; ...@@ -2,39 +2,34 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.text.InputType; import android.text.InputType;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.Toast; import android.widget.Toast;
import com.yottacode.pictogram.action.VocabularyAction;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.grammar.Vocabulary; import com.yottacode.pictogram.grammar.Vocabulary;
import com.yottacode.pictogram.grammar.iLocalPicto; import com.yottacode.pictogram.grammar.iLocalPicto;
import com.yottacode.pictogram.net.PictoUploader; import com.yottacode.pictogram.net.PictoUploader;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.cropper.CropImageView;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import static android.graphics.Color.BLACK;
import static android.graphics.Color.argb; import static android.graphics.Color.argb;
import static android.graphics.Color.rgb;
public class PictoMenu { public class PictoMenu {
...@@ -42,6 +37,9 @@ public class PictoMenu { ...@@ -42,6 +37,9 @@ public class PictoMenu {
PictogramActivity activity; PictogramActivity activity;
//Variables used on the picto menu (only supervisors) //Variables used on the picto menu (only supervisors)
private static final int CAMERA_PIC_REQUEST = 1;
private static final int GALLERY_PIC_REQUEST = 2;
private RadialMenuWidget PieMenu; private RadialMenuWidget PieMenu;
private ImageView detail; private ImageView detail;
private RelativeLayout ll; private RelativeLayout ll;
...@@ -62,8 +60,38 @@ public class PictoMenu { ...@@ -62,8 +60,38 @@ public class PictoMenu {
*/ */
public void addPicto(int row, int col) { public void addPicto(int row, int col) {
Intent intent = new Intent(Intent.ACTION_PICK); final String [] items = new String [] {activity.getString(R.string.dialogCamera), activity.getString(R.string.dialogGallery)};
intent.setType("image/*"); ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, android.R.layout.select_dialog_item, items);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(activity.getString(R.string.dialogTitle));
builder.setAdapter( adapter, new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog, int item ) {
if (item == 0) { //Pick from camera
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
activity.startActivityForResult(cameraIntent,CAMERA_PIC_REQUEST);
} else { //Pick from file
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
activity.startActivityForResult(intent,GALLERY_PIC_REQUEST);
}
}
} );
builder.setNegativeButton(activity.getString(R.string.dialogCancel),new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
final AlertDialog dialog = builder.create();
dialog.show();
/*Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image*//*");
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) { if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
activity.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row); activity.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col); activity.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col);
...@@ -71,8 +99,7 @@ public class PictoMenu { ...@@ -71,8 +99,7 @@ public class PictoMenu {
activity.getIntent().putExtra(Picto.JSON_ATTTRS.FREE_ROW, row); activity.getIntent().putExtra(Picto.JSON_ATTTRS.FREE_ROW, row);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col); activity.getIntent().putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col);
} }
activity.startActivityForResult(intent, SELECT_PICTURE); activity.startActivityForResult(intent,CAMERA_PIC_REQUEST);*/
} }
...@@ -180,92 +207,8 @@ public class PictoMenu { ...@@ -180,92 +207,8 @@ public class PictoMenu {
/**Function for open a new View for change the expression of a picto
*
* @param picto
*/
public void createViewForExpression(final Picto picto){
ll = new RelativeLayout(PCBcontext.getContext());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
activity.addContentView(ll, params);
ll.setBackgroundColor(argb(180,0,0,0));
ll.setClickable(false);
//Parameters for hide navigation bar when u save or cancel
final View decorView = activity.getWindow().getDecorView();
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
/*| View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE*/;
final EditText leyenda = new EditText(PCBcontext.getContext());
leyenda.setBackgroundColor(rgb(221, 221, 211));
leyenda.setWidth(400);
leyenda.setMaxLines(1);
leyenda.setClickable(true);
leyenda.setTextSize(25);
leyenda.setX(activity.getResources().getDisplayMetrics().widthPixels/2 - 300);
leyenda.setY(activity.getResources().getDisplayMetrics().heightPixels/2 - 50);
leyenda.setTextColor(BLACK);
if(picto.get_translation()!= null && picto != null){
leyenda.setText(picto.get_translation());
}else{
leyenda.setText("Sin Descripción");
}
//Mostrar teclado automaticamente
final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
ImageButton botonOk = new ImageButton(PCBcontext.getContext());
botonOk.setImageResource(android.R.drawable.ic_menu_save);
botonOk.setX(activity.getResources().getDisplayMetrics().widthPixels/2 + 110);
botonOk.setY(activity.getResources().getDisplayMetrics().heightPixels/2 - 50);
botonOk.setBackgroundColor(rgb(221,221,221));
botonOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
picto.set_translation(leyenda.getText().toString());
imm.hideSoftInputFromWindow(leyenda.getWindowToken(), 0);
picto.set_local_status(true);
if (!picto.is_local()) {
new PictoUploader(picto).uploadState();
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS, picto));
}
activity.getCurrentPictoGridAdapter().notifyDataSetChanged();
ll.setVisibility(View.GONE);
ll.removeAllViewsInLayout();
//Hide navigation bar
//activity.refresh();
decorView.setSystemUiVisibility(uiOptions);
}
});
ImageButton botonSalir = new ImageButton(PCBcontext.getContext());
botonSalir.setImageResource(android.R.drawable.ic_menu_close_clear_cancel);
botonSalir.setX(activity.getResources().getDisplayMetrics().widthPixels/2 + 150);
botonSalir.setY(activity.getResources().getDisplayMetrics().heightPixels/2 - 50);
botonSalir.setBackgroundColor(rgb(221,221,221));
botonSalir.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imm.hideSoftInputFromWindow(leyenda.getWindowToken(), 0);
ll.setVisibility(View.GONE);
ll.removeAllViewsInLayout();
//Hide navigation bar
//activity.refresh();
decorView.setSystemUiVisibility(uiOptions);
}
});
ll.addView(leyenda);
ll.addView(botonOk);
ll.addView(botonSalir);
leyenda.requestFocus();
imm.showSoftInput(leyenda, InputMethodManager.SHOW_FORCED);
}
/**Function for build a radial menu /**Function for build a radial menu
* *
* @param is_picto_big * @param is_picto_big
...@@ -303,7 +246,7 @@ public class PictoMenu { ...@@ -303,7 +246,7 @@ public class PictoMenu {
PieMenu.addMenuEntry(new UnlockPictoMenu(picto)); PieMenu.addMenuEntry(new UnlockPictoMenu(picto));
PieMenu.addMenuEntry(new DisablePictoMenu(picto)); PieMenu.addMenuEntry(new DisablePictoMenu(picto));
PieMenu.addMenuEntry(new SetInvisibleMenu(picto)); PieMenu.addMenuEntry(new SetInvisibleMenu(picto));
//PieMenu.addMenuEntry(new EditMenu(picto)); PieMenu.addMenuEntry(new EditMenu(picto));
ll.addView(PieMenu); ll.addView(PieMenu);
...@@ -328,7 +271,7 @@ public class PictoMenu { ...@@ -328,7 +271,7 @@ public class PictoMenu {
} }
public String getName() { return "Close"; } public String getName() { return "Close"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return android.R.drawable.ic_menu_close_clear_cancel; } public int getIcon() { return android.R.drawable.ic_menu_revert; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; } public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
//Metodo para realizar acciones si se pulsa //Metodo para realizar acciones si se pulsa
public void menuActiviated() public void menuActiviated()
...@@ -413,33 +356,13 @@ public class PictoMenu { ...@@ -413,33 +356,13 @@ public class PictoMenu {
} }
public String getName() { return "edit"; } public String getName() { return "edit"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.edit; } public int getIcon() { return android.R.drawable.ic_menu_edit; }
private List<RadialMenuWidget.RadialMenuEntry> children; private List<RadialMenuWidget.RadialMenuEntry> children;
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return children; } public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return children; }
public void menuActiviated() public void menuActiviated()
{ {
/*ll.getChildAt(1).setX(ll.getChildAt(1).getX() + 30); ll.getChildAt(1).setX(ll.getChildAt(1).getX() + 30);
children = new ArrayList<>(Arrays.asList(new EditTextPicto(p),new EditImage(p)));*/ children = new ArrayList<>(Arrays.asList(new PickFromCamera(p),new PickFromGallery(p)));
activity.setContentView(R.layout.crop_layout);
final CropImageView cropImageView = (CropImageView) activity.findViewById(R.id.CropImageView);
cropImageView.setImageResource(R.drawable.common_full_open_on_phone);
final ImageView croppedImageView = (ImageView) activity.findViewById(R.id.croppedImageView);
final Button cropButton = (Button) activity.findViewById(R.id.Button_crop);
cropImageView.setGuidelines(CropImageView.GUIDELINES_ON); //To show the guidelines
cropImageView.setFixedAspectRatio(true);
cropImageView.setAspectRatio(1,1);
cropButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Bitmap croppedImage = cropImageView.getCroppedImage();
croppedImageView.setImageBitmap(croppedImage);
}
});
} }
public void menuDisabled(){ public void menuDisabled(){
...@@ -448,42 +371,56 @@ public class PictoMenu { ...@@ -448,42 +371,56 @@ public class PictoMenu {
} }
//Edit legend text of picto button //Edit legend text of picto button
public class EditTextPicto implements RadialMenuWidget.RadialMenuEntry public class PickFromCamera implements RadialMenuWidget.RadialMenuEntry
{ {
Picto p; Picto p;
public EditTextPicto(Picto picto){ public PickFromCamera(Picto picto){
p = picto; p = picto;
} }
public String getName() { return "editText"; } public String getName() { return "editText"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.edit_text; } public int getIcon() { return android.R.drawable.ic_menu_camera; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; } public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated() public void menuActiviated()
{ {
ll.setVisibility(View.GONE); ll.setVisibility(View.GONE);
ll.removeAllViewsInLayout(); ll.removeAllViewsInLayout();
createViewForExpression(p);
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
if(p!=null) {
//cameraIntent.putExtra("pictoLegend", p.get_translation());
activity.setPicto(p);
}
activity.startActivityForResult(cameraIntent,CAMERA_PIC_REQUEST);
} }
public void menuDisabled(){} public void menuDisabled(){}
} }
public class EditImage implements RadialMenuWidget.RadialMenuEntry public class PickFromGallery implements RadialMenuWidget.RadialMenuEntry
{ {
Picto p; Picto p;
public EditImage(Picto picto){ public PickFromGallery(Picto picto){
p = picto; p = picto;
} }
public String getName() { return "editImage"; } public String getName() { return "editImage"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.edit_picture; } public int getIcon() { return android.R.drawable.ic_menu_gallery; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; } public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated() public void menuActiviated()
{ {
/**TODO: Llamar a la interfaz de editar foto*/ ll.setVisibility(View.GONE);
Toast.makeText(PCBcontext.getContext(),"Editar Imagen", Toast.LENGTH_SHORT).show(); ll.removeAllViewsInLayout();
if(p!=null) {
//cameraIntent.putExtra("pictoLegend", p.get_translation());
activity.setPicto(p);
}
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
activity.startActivityForResult(intent,GALLERY_PIC_REQUEST);
//addPicto(p.get_row(),p.get_column());
} }
public void menuDisabled(){} public void menuDisabled(){}
} }
} }
...@@ -8,12 +8,16 @@ import android.content.ClipDescription; ...@@ -8,12 +8,16 @@ import android.content.ClipDescription;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.media.Ringtone; import android.media.Ringtone;
import android.media.RingtoneManager; import android.media.RingtoneManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.MediaStore;
import android.speech.tts.UtteranceProgressListener; import android.speech.tts.UtteranceProgressListener;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
...@@ -46,6 +50,7 @@ import com.yottacode.pictogram.net.ImgDownloader; ...@@ -46,6 +50,7 @@ import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.net.websockets.ActionTalk; import com.yottacode.pictogram.net.websockets.ActionTalk;
import com.yottacode.pictogram.net.websockets.VocabularyTalk; import com.yottacode.pictogram.net.websockets.VocabularyTalk;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.cropper.EditPictoActivity;
import com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity; import com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity;
import com.yottacode.pictogram.tabletlibrary.gui.session.SessionActivity; import com.yottacode.pictogram.tabletlibrary.gui.session.SessionActivity;
import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet; import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
...@@ -56,6 +61,7 @@ import com.yottacode.pictogram.tts.TTSHelper; ...@@ -56,6 +61,7 @@ import com.yottacode.pictogram.tts.TTSHelper;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -66,6 +72,12 @@ import java.util.concurrent.TimeUnit; ...@@ -66,6 +72,12 @@ 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 GALLERY_PIC_REQUEST = 2;
private static final int MAX_WIDTH = 700;
private static final int MAX_HEIGHT = 350;
// Main layout for this activity // Main layout for this activity
RelativeLayout mainLayout; RelativeLayout mainLayout;
...@@ -675,6 +687,14 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -675,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
* ********************************************************************************************/ * ********************************************************************************************/
...@@ -822,8 +842,6 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -822,8 +842,6 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
if (p == null) { if (p == null) {
// No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device si no es categoria // No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device si no es categoria
if (currentCategory != null || !PCBcontext.getPcbdb().getCurrentUser().has_categories()) { if (currentCategory != null || !PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
Log.d(LOG_TAG, "No tengo pictograma. Abro carrete...");
new PictoMenu(PictogramActivity.this).addPicto(position % maxColumns, (int) (position / maxColumns)); new PictoMenu(PictogramActivity.this).addPicto(position % maxColumns, (int) (position / maxColumns));
} else } else
Toast.makeText(PictogramActivity.this, PictogramActivity.this.getResources().getString(R.string.notNewCats), Toast.LENGTH_SHORT).show(); Toast.makeText(PictogramActivity.this, PictogramActivity.this.getResources().getString(R.string.notNewCats), Toast.LENGTH_SHORT).show();
...@@ -1065,4 +1083,107 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1065,4 +1083,107 @@ protected void showOnlyTape(boolean onlyTape) {
return super.dispatchTouchEvent(event); return super.dispatchTouchEvent(event);
} }
/**
* Para capturar el evento para abrir camara o galeria y procesar
* @param requestCode
* @param resultCode
* @param data
*/
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
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);
//Log.i("DETALLES", "Llega el intent del menú, con texto: " + legend);
} 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));
}
break;
case GALLERY_PIC_REQUEST: //Galeria
if(data!=null){
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
imagen = BitmapFactory.decodeFile(filePath);
/** 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 */
//-->GERMAN: legend != null ? legend : null es lo mismo que simplemente legend
this.launchActivity(imagen);
}else{
startActivity(new Intent(this, PictogramActivity.class));
}
break;
case EditPictoActivity.EDIT_PICTO_REQUEST:
if (resultCode == RESULT_OK)
Log.i("DETALLES", "Llega el intent de recorte 2, texto: " + data.getExtras().getString(EditPictoActivity.TRANSCRIPTION));
}
}
/**Para cambiar la activity de PictogramActivity a EditPictoActivity
* @param image
*/
public void launchActivity(Bitmap image){
Intent intent = new Intent(this, EditPictoActivity.class);
if(image!=null) {
float aspectFactor = 1;
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;
}
Bitmap rescaled = Bitmap.createScaledBitmap(image,(int) bWidth, (int) bHeight, true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra(EditPictoActivity.IMAGE_PICTO, byteArray);
if(picto!=null) {
intent.putExtra(EditPictoActivity.TRANSCRIPTION, picto.get_translation());
picto = null;
}
startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST);
}
}
/*@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// Esto es lo que hace mi botón al pulsar ir a atrás
finish();
Intent intent =
return true;
}
return super.onKeyDown(keyCode, event);
}*/
} }
<?xml version="1.0" encoding="utf-8"?>
<!--<ScrollView
android:id="@+id/scrollview"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".cropper.MainCropImage"
android:background="@color/black_translucent">
-->
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black_translucent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:id="@+id/ScrollView">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/TotalLayout">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/titleCropper"
android:textSize="24sp"
android:textStyle="bold"
android:textColor="@color/common_google_signin_btn_text_dark_pressed"
android:layout_weight="1"
android:textAlignment="center"
android:layout_gravity="top"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<com.yottacode.pictogram.tabletlibrary.cropper.CropImageView
android:id="@+id/CropImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:layout_below="@+id/title"
android:layout_alignParentStart="true" />
<Button
android:id="@+id/Button_crop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="120dp"
android:text="@string/crop"
android:textColor="#33B5E5"
android:textSize="20sp"
android:layout_gravity="center_vertical"
android:layout_marginTop="2dp"
android:layout_below="@+id/title"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/croppedImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:adjustViewBounds="true"
android:contentDescription="@string/croppedImageDesc"
android:scaleType="centerInside"/>
</RelativeLayout>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<!--<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:id="@+id/TotalLayout"
android:background="#b4000000">-->
<!--<FrameLayout
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">-->
<!--<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:id="@+id/backgroundImage"
app:srcCompat="@color/black_translucent" />-->
<RelativeLayout
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:id="@+id/TotalLayout"
android:background="@color/black_translucent">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
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: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">
<com.yottacode.pictogram.tabletlibrary.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_marginLeft="5dp"
android:maxWidth="700px"
android:maxHeight="350px"
android:layout_below="@+id/title"
android:layout_alignParentStart="true"
android:layout_marginTop="55dp"
android:minHeight="125dp"
android:layout_gravity="center_horizontal" />
<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:textColor="#33B5E5"
android:textSize="20sp"
android:textAlignment="center"
android:layout_alignParentBottom="true"
android:layout_toStartOf="@+id/cancelButton"
android:width="70dp"
android:layout_marginRight="10dp" />
<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>
</RelativeLayout>
<!--</FrameLayout>-->
...@@ -34,5 +34,15 @@ ...@@ -34,5 +34,15 @@
<string name="session_eval_model">modeled</string> <string name="session_eval_model">modeled</string>
<string name="session_eval_notevuated">not evaluated</string> <string name="session_eval_notevuated">not evaluated</string>
<string name="session_eval_discarded">discarded</string> <string name="session_eval_discarded">discarded</string>
<string name="crop">Crop</string>
<string name="titleCropper">Edit Picto</string>
<string name="croppedImageDesc">Preview</string>
<string name="cancel">Cancel</string>
<string name="accept">Accept</string>
<string name="legendText">Legend</string>
<string name="dialogCamera">Take a Picture</string>
<string name="dialogGallery">Pick from Gallery</string>
<string name="dialogTitle">Choose Method</string>
<string name="dialogCancel">Cancel</string>
</resources> </resources>
...@@ -34,4 +34,14 @@ ...@@ -34,4 +34,14 @@
<string name="session_eval_model">modelado</string> <string name="session_eval_model">modelado</string>
<string name="session_eval_notevuated">no evaluado</string> <string name="session_eval_notevuated">no evaluado</string>
<string name="session_eval_discarded">inválido</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="dialogCamera">Hacer Foto</string>
<string name="dialogGallery">Seleccionar de Galería</string>
<string name="dialogTitle">Seleccionar Método</string>
<string name="dialogCancel">Cancelar</string>
</resources> </resources>
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
</declare-styleable> </declare-styleable>
</resources> </resources>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<resources> <resources>
<color name="white_translucent">#AAFFFFFF</color> <color name="white_translucent">#AAFFFFFF</color>
<color name="black_translucent">#b0000000</color> <color name="black_translucent">#b4000000</color>
<color name="border">@color/white_translucent</color> <color name="border">@color/white_translucent</color>
<color name="guideline">@color/white_translucent</color> <color name="guideline">@color/white_translucent</color>
......
...@@ -38,14 +38,21 @@ ...@@ -38,14 +38,21 @@
<string name="session_eval_discarded">inválido</string> <string name="session_eval_discarded">inválido</string>
<!-- Dialog for add new picto -->
<string name="dialogTitle">Seleccionar método</string>
<string name="dialogCamera">Hacer Foto</string>
<string name="dialogGallery">Seleccionar de Galería</string>
<string name="dialogCancel">Cancelar</string>
<!-- Cropper --> <!-- Cropper -->
<string name="titleCropper">Cropper</string> <string name="legendText">Leyenda</string>
<string name="titleCropper">Editar Picto</string>
<string name="fixedAspectRatio">fixedAspectRatio =\u0020</string> <string name="fixedAspectRatio">fixedAspectRatio =\u0020</string>
<string name="aspectRatioXHeader">aspectRatioX =\u0020</string> <string name="aspectRatioXHeader">aspectRatioX =\u0020</string>
<string name="aspectRatioYHeader">aspectRatioY =\u0020</string> <string name="aspectRatioYHeader">aspectRatioY =\u0020</string>
<string name="showGuidelines">showGuidelines =\u0020</string> <string name="showGuidelines">showGuidelines =\u0020</string>
<string name="crop">Crop</string> <string name="accept">Aceptar</string>
<string name="croppedImageDesc">The cropped image.</string> <string name="cancel">Cancel</string>
<string name="croppedImageDesc">Vista Previa</string>
<string-array name="showGuidelinesArray"> <string-array name="showGuidelinesArray">
<item>Off</item> <item>Off</item>
......
...@@ -73,14 +73,6 @@ ...@@ -73,14 +73,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<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" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
...@@ -89,6 +81,14 @@ ...@@ -89,6 +81,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<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/annotations" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......
...@@ -66,14 +66,6 @@ ...@@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/assets" type="java-test-resource" />
...@@ -82,6 +74,14 @@ ...@@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
...@@ -106,14 +106,6 @@ ...@@ -106,14 +106,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
...@@ -122,6 +114,14 @@ ...@@ -122,6 +114,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" /> <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/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
......
...@@ -73,5 +73,12 @@ ...@@ -73,5 +73,12 @@
android:launchMode="singleInstance" android:launchMode="singleInstance"
android:screenOrientation="landscape" /> android:screenOrientation="landscape" />
<activity
android:name="com.yottacode.pictogram.tabletlibrary.cropper.EditPictoActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:screenOrientation="landscape" />
</application> </application>
</manifest> </manifest>
...@@ -66,14 +66,6 @@ ...@@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/assets" type="java-test-resource" />
...@@ -82,6 +74,14 @@ ...@@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......
Changes to be performed manually in servers to upgrade
AngularJS
- angular-re-captcha has been replaced by angular-recaptcha, so bower has to be run
- reinstall ui-bootstrap
- replace angular-file-upload by ng-file-upload
Database
- reload trigers-enrolments-integrity-constraints.sql
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html lang="en" ng-app="dashboardApp"> <html lang="en" ng-app="dashboardApp">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Pictogram Dashboard</title> <title>Pictogram Web</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="css/main.css"> <link rel="stylesheet" href="css/main.css">
<link rel="icon" href="img/logo_pictogram.png" type='image/png'> <link rel="icon" href="img/logo_pictogram.png" type='image/png'>
......
...@@ -175,8 +175,8 @@ dashboardApp.config(function ($stateProvider, $urlRouterProvider) { ...@@ -175,8 +175,8 @@ dashboardApp.config(function ($stateProvider, $urlRouterProvider) {
}) })
.state('admin_login', { .state('admin_login', {
url: '/admin/login', url: '/admin/login',
templateUrl: 'modules/login/views/login_admin.html', // TODO: habría que mover esta vista a modules/admin/views templateUrl: 'modules/admin/views/login.html',
controller: 'LoginAdminCtrl', // TODO: y el controlador, también controller: 'LoginAdminCtrl',
}) })
.state('admin_licenses', { .state('admin_licenses', {
url: '/admin/licenses', url: '/admin/licenses',
......
...@@ -25,9 +25,7 @@ ...@@ -25,9 +25,7 @@
<img ng-src="{{ croppedDataUrl }}" /> <img ng-src="{{ croppedDataUrl }}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<button class="btn btn-default" ng-click="crop(croppedDataUrl, picFile.name)" ng-model="picFile" accept="image/*">
<span class="glyphicon glyphicon-upload"></span> {{ 'upload_image' | translate }}
</button>
</div> </div>
<div class="form-group"> <div class="form-group">
<span class="progress" ng-show="progress > 0"> <span class="progress" ng-show="progress > 0">
...@@ -40,6 +38,11 @@ ...@@ -40,6 +38,11 @@
</div> <!-- /modal-body --> </div> <!-- /modal-body -->
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-click="cancel()">{{ 'close' | translate }}</button> <button class="btn btn-danger" ng-click="cancel()">
<i class="fa fa-times-circle" aria-hidden="true"></i> Cancelar
</button>
<button class="btn btn-success" ng-click="crop(croppedDataUrl, picFile.name)" ng-model="picFile" accept="image/*">
<i class="fa fa-upload" aria-hidden="true"></i> {{ 'upload_image' | translate }}
</button>
</div> </div>
</div> </div>
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
<h4 class="modal-title" id="myModalLabel" translate>add_expression</h4> <h4 class="modal-title" id="myModalLabel" translate>add_expression</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form ng-submit="save()"> <form ng-submit="save()">
<div id="add_label" class="input-group"> <div id="add_label" class="input-group">
<span class="input-group-addon glyphicon glyphicon-comment" aria-hidden="true"></span> <span class="input-group-addon glyphicon glyphicon-comment" aria-hidden="true"></span>
<input type="text" class="form-control" ng-model="expression" /> <input type="text" class="form-control" ng-model="expression" autofocus/>
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-success" type="submit" translate>save</button> <button class="btn btn-success" type="submit" translate>save</button>
</span> </span>
...@@ -19,4 +19,4 @@ ...@@ -19,4 +19,4 @@
</div> </div>
<!-- End modal-body --> <!-- End modal-body -->
</div> </div>
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
//----------------------- //-----------------------
// Supervisor Controller // Supervisor Controller
//----------------------- //-----------------------
dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl($scope, $window, $location, IOService) { dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl($scope, $window, $location, IOService, $modal) {
// Restore user data from session // Restore user data from session
var user = JSON.parse($window.sessionStorage.user); var user = JSON.parse($window.sessionStorage.user);
...@@ -32,4 +32,62 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl($scope ...@@ -32,4 +32,62 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl($scope
id_sup: $scope.user.id id_sup: $scope.user.id
} }
}); });
//
// Own Pictos
//
$scope.own_pictos = function () {
console.log();
var modalInstance = $modal.open({
animation: true,
templateUrl: 'modules/supervisor/views/own_pictos.html',
controller: 'AddPictoCtrl',
size: 'lg',
resolve: {
student: function () {
return $scope.studentData;
},
supervisor: function () {
return $scope.user;
}
}
});
// Returned data from the modal window
modalInstance.result.then(function (pictoId) {
// Send the picto to the server
$http.post(config.backend + '/stu/' + $scope.studentData.id + '/picto/' + pictoId, {
attributes: {
id_cat: $scope.showFreeCategory ? null : $scope.getCategoryId($scope.selectedCategory),
coord_x: $scope.showFreeCategory ? null : col,
coord_y: $scope.showFreeCategory ? null : row,
status: 'enabled',
free_category_coord_x: $scope.showFreeCategory ? col : null,
free_category_coord_y: $scope.showFreeCategory ? row : null
}
})
.success(function (studentPicto) {
console.log(studentPicto);
placePicto(studentPicto);
io.socket.post('/stu/vocabulary', {
action: 'add',
attributes: {
id_stu: $scope.studentData.id,
stu_picto: studentPicto
}
}, function () {});
})
.error(function (err) {
if (err.code && err.code == 1) // codes are in sails/config/pictogram.js
ngToast.danger({ content: $translate.instant('error_duplicated_picto') });
else
ngToast.danger({ content: $translate.instant('error_adding_picto') });
});
// not needed
// $scope.loadPictos();
});
};
}); });
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
</a> </a>
</li> </li>
<li> <li>
<a class="pointer" role="menuitem" tabindex="0" href=""> <a ng-click="own_pictos()" class="pointer" role="menuitem" tabindex="0" href="">
<i class="glyphicon glyphicon-picture" aria-hidden="true"></i> <i class="glyphicon glyphicon-picture" aria-hidden="true"></i>
{{ 'own_pictos' | translate }} {{ 'own_pictos' | translate }}
</a> </a>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" id="student_license" mask="9999-9999-9999-9999" clean="true" placeholder="{{ 'license_number' | translate }}" ng-model="formdatastudent.license_number" required> <input class="form-control" type="text" id="student_license" mask="9999-9999-9999-9999" clean="true" placeholder="{{ 'license_number' | translate }}" ng-model="formdatastudent.license_number" required>
</div> </div>
......
...@@ -3,12 +3,45 @@ ...@@ -3,12 +3,45 @@
//---------------------- //----------------------
// Translate Controller // Translate Controller
//---------------------- //----------------------
dashboardControllers.controller('TranslateController', function($translate, $scope, vcRecaptchaService) { dashboardControllers.controller('TranslateController', function(
$translate,
$scope,
$window,
$http,
config,
ngToast,
vcRecaptchaService
) {
$scope.changeLanguage = function (langKey) { $scope.changeLanguage = function (langKey) {
//Translate update
$translate.use(langKey); $translate.use(langKey);
//Scope update
$scope.user.lang = langKey; $scope.user.lang = langKey;
//Update supervisor language
if ($window.sessionStorage.user) {
//Session variables update
var obj = JSON.parse($window.sessionStorage.user);
obj.lang = langKey;
$window.sessionStorage.user = JSON.stringify(obj);
//Server PUT
$http.put(config.backend + '/sup/' + $scope.user.id, { "lang": langKey })
.success(function (data) {
ngToast.success({ content: $translate.instant('data_saved') });
console.log("OK: Update supervisor language");
})
.error(function () {
ngToast.danger({ content: $translate.instant('data_no_saved') });
console.log("Error: Update supervisor language");
});
}
// Reload captcha according to language (only once instance per page, so id is always 0) // Reload captcha according to language (only once instance per page, so id is always 0)
vcRecaptchaService.useLang(0, langKey.substr(0,2)); vcRecaptchaService.useLang(0, langKey.substr(0,2)); //TODO: REVISAR reCaptcha Widget ID not exists
}; };
}); });
...@@ -44,7 +44,7 @@ module.exports = function (grunt) { ...@@ -44,7 +44,7 @@ module.exports = function (grunt) {
'assets/scripts/modules/login/controllers/login.js', 'assets/scripts/modules/login/controllers/login.js',
'assets/scripts/modules/login/controllers/login_setting_password.js', 'assets/scripts/modules/login/controllers/login_setting_password.js',
'assets/scripts/modules/login/controllers/signin.js', 'assets/scripts/modules/login/controllers/signin.js',
'assets/scripts/modules/login/controllers/login_admin.js', 'assets/scripts/modules/admin/controllers/login.js',
'assets/scripts/modules/admin/controllers/admin.js', 'assets/scripts/modules/admin/controllers/admin.js',
'assets/scripts/modules/admin/controllers/licenses.js', 'assets/scripts/modules/admin/controllers/licenses.js',
'assets/scripts/modules/admin/controllers/offices.js', 'assets/scripts/modules/admin/controllers/offices.js',
......
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