Commit 108bffc6 by Jose Antonio

Merged branch develop into develop

parents f809bc90 dd79da49
Showing with 655 additions and 346 deletions
......@@ -11,7 +11,7 @@ android {
versionName "1.0"
resValue "string", "db_name", "PCB.db"
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", "apk", "to_be_set_in_subproject"
}
......
......@@ -209,7 +209,7 @@ public class Vocabulary implements Iterable<Picto> {
@Override
public void error(RestapiWrapper.HTTPException e) {
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 @@
<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/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/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/assets" type="java-test-resource" />
......@@ -82,6 +74,14 @@
<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/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/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......
......@@ -250,9 +250,6 @@ public class CropImageView extends ImageView {
* @return a new Bitmap representing the cropped image
*/
public Bitmap getCroppedImage() {
// Implementation reference: http://stackoverflow.com/a/26930938/1068656
final Drawable drawable = this.getDrawable();
if (drawable == null || !(drawable instanceof BitmapDrawable)) {
return null;
......@@ -271,15 +268,15 @@ public class CropImageView extends ImageView {
final float transY = matrixValues[Matrix.MTRANS_Y];
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","Edge Left: "+Edge.LEFT.getCoordinate() + "- Edge Top: "+Edge.TOP.getCoordinate());
Log.i("DETALLES","ancho original: "+originalBitmap.getWidth() + " Alto original: "+originalBitmap.getHeight());
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: "+cropWidth + " Alto: "+cropHeight);
/*Log.i("DETALLES","ancho original: "+originalBitmap.getWidth() + " Alto original: "+originalBitmap.getHeight());
Log.i("DETALLES","ancho: "+cropWidth + " Alto: "+cropHeight);*/
// 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 bitmapTop = (transY < 0) ? Math.abs(transY) : 0;*/
......@@ -287,17 +284,17 @@ public class CropImageView extends ImageView {
// Get the original bitmap object.
//final Bitmap originalBitmap = ((BitmapDrawable) drawable).getBitmap();
final float bitmapLeft = ((findViewById(R.id.ScrollView)).getWidth() - originalBitmap.getWidth())/2;
final float bitmapTop = ((findViewById(R.id.ScrollView)).getHeight() - originalBitmap.getHeight())/2;
/*final float bitmapLeft = ((findViewById(R.id.ScrollView)).getWidth() - originalBitmap.getWidth())/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.
final float cropX = (bitmapLeft + Edge.LEFT.getCoordinate());
final float cropY = (bitmapTop + 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.
// 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 {
Log.i("DETALLES","ancho: "+cropWidth + " Alto: "+cropHeight);*/
// Crop the subset from the original Bitmap.
return Bitmap.createBitmap(originalBitmap,
(int) cropX,
(int) cropY,
(int) cropWidth,
(int) cropHeight);
(int) (Edge.LEFT.getCoordinate() - transX),
(int) (Edge.TOP.getCoordinate() - transY),
(int) Edge.getWidth(),
(int) Edge.getHeight());
}
......@@ -573,4 +570,7 @@ public class CropImageView extends ImageView {
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;
public class PictoItemViewGenerator {
public static final int LAYOUT = R.layout.picto_grid_item;
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 String LOG_TAG = PictoItemViewGenerator.class.getCanonicalName();
public static int mirror_color=0;
......@@ -40,8 +40,11 @@ public class PictoItemViewGenerator {
* @param picto Pictogram to set the legend text
* @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();
if(!isFull) return texto;
WordTools wordTools=new WordTools();
if (texto.length()>maxlength) {
String[] words = texto.split(" ");
......@@ -73,7 +76,7 @@ public class PictoItemViewGenerator {
int width = bitmap.getWidth(); //Ancho 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
android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
......@@ -126,7 +129,7 @@ public class PictoItemViewGenerator {
textView.setWidth(100);
textView.setGravity(Gravity.CENTER);
textView.setMaxLines(3);
textView.setText(texto);
//textView.setText(texto);
textView.setDrawingCacheEnabled(true);
canvas.drawBitmap(textView.getDrawingCache(), 0, 25, null);
......@@ -169,64 +172,66 @@ public class PictoItemViewGenerator {
.getColor(R.color.picto_default_background));
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);
pictoImage.setVisibility(View.VISIBLE);
layoutWrapper.setBackground(convertView.getResources()
.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) {
layoutWrapper.setAlpha(!picto.is_invisible() ? 1.00f : PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? 0.25f : 0f );
try {
Bitmap bm = picto.get_bitmap(PCBcontext.getContext());
switch (picto.get_legend()) {
case "none":
legend.setVisibility(View.GONE);
legend_full.setVisibility(View.GONE);
break;
case "normal":
legend.setText(format_legend(picto,MAX_LINE_LENGTH));
legend.setVisibility(View.VISIBLE);
legend_full.setVisibility(View.GONE);
break;
default:
legend_full.setText(format_legend(picto,MAX_LINE_LENGTH_FULL));
legend.setVisibility(View.GONE);
legend_full.setVisibility(View.VISIBLE);
if (picto!=null) {
layoutWrapper.setAlpha(!picto.is_invisible() ? 1.00f : PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? 0.25f : 0f);
try {
Bitmap bm = picto.get_bitmap(PCBcontext.getContext());
switch (picto.get_legend()) {
case "none":
legend.setVisibility(View.GONE);
legend_full.setVisibility(View.GONE);
break;
case "normal":
legend.setText(format_legend(picto, MAX_LINE_LENGTH, false));
legend.setVisibility(View.VISIBLE);
legend_full.setVisibility(View.GONE);
break;
default:
legend_full.setText(format_legend(picto, MAX_LINE_LENGTH_FULL, true));
legend.setVisibility(View.GONE);
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();
}
}
......
......@@ -8,12 +8,16 @@ import android.content.ClipDescription;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.speech.tts.UtteranceProgressListener;
import android.util.DisplayMetrics;
import android.util.Log;
......@@ -46,6 +50,7 @@ import com.yottacode.pictogram.net.ImgDownloader;
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.login.SerialActivity;
import com.yottacode.pictogram.tabletlibrary.gui.session.SessionActivity;
import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
......@@ -56,6 +61,7 @@ import com.yottacode.pictogram.tts.TTSHelper;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
......@@ -66,6 +72,12 @@ import java.util.concurrent.TimeUnit;
public class PictogramActivity extends Activity implements VocabularyTalk.iVocabularyListener {
private Picto picto = null;
private static final int CAMERA_PIC_REQUEST = 1;
private static final int GALLERY_PIC_REQUEST = 2;
private static final int MAX_WIDTH = 700;
private static final int MAX_HEIGHT = 350;
// Main layout for this activity
RelativeLayout mainLayout;
......@@ -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
* ********************************************************************************************/
......@@ -822,8 +842,6 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
if (p == null) {
// 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()) {
Log.d(LOG_TAG, "No tengo pictograma. Abro carrete...");
new PictoMenu(PictogramActivity.this).addPicto(position % maxColumns, (int) (position / maxColumns));
} else
Toast.makeText(PictogramActivity.this, PictogramActivity.this.getResources().getString(R.string.notNewCats), Toast.LENGTH_SHORT).show();
......@@ -1065,4 +1083,107 @@ protected void showOnlyTape(boolean onlyTape) {
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 @@
<string name="session_eval_model">modeled</string>
<string name="session_eval_notevuated">not evaluated</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>
......@@ -34,4 +34,14 @@
<string name="session_eval_model">modelado</string>
<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="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>
......@@ -14,4 +14,4 @@
</declare-styleable>
</resources>
\ No newline at end of file
</resources>
......@@ -2,7 +2,7 @@
<resources>
<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="guideline">@color/white_translucent</color>
......
......@@ -38,14 +38,21 @@
<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 -->
<string name="titleCropper">Cropper</string>
<string name="legendText">Leyenda</string>
<string name="titleCropper">Editar Picto</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="crop">Crop</string>
<string name="croppedImageDesc">The cropped image.</string>
<string name="accept">Aceptar</string>
<string name="cancel">Cancel</string>
<string name="croppedImageDesc">Vista Previa</string>
<string-array name="showGuidelinesArray">
<item>Off</item>
......
......@@ -73,14 +73,6 @@
<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/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/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
......@@ -89,6 +81,14 @@
<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/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/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......
......@@ -66,14 +66,6 @@
<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/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/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/assets" type="java-test-resource" />
......@@ -82,6 +74,14 @@
<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/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/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......@@ -106,14 +106,6 @@
<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/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/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
......@@ -122,6 +114,14 @@
<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/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/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
......
......@@ -73,5 +73,12 @@
android:launchMode="singleInstance"
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>
</manifest>
......@@ -66,14 +66,6 @@
<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/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/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/assets" type="java-test-resource" />
......@@ -82,6 +74,14 @@
<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/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/resources" 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 @@
<html lang="en" ng-app="dashboardApp">
<head>
<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">
<link rel="stylesheet" href="css/main.css">
<link rel="icon" href="img/logo_pictogram.png" type='image/png'>
......
......@@ -175,8 +175,8 @@ dashboardApp.config(function ($stateProvider, $urlRouterProvider) {
})
.state('admin_login', {
url: '/admin/login',
templateUrl: 'modules/login/views/login_admin.html', // TODO: habría que mover esta vista a modules/admin/views
controller: 'LoginAdminCtrl', // TODO: y el controlador, también
templateUrl: 'modules/admin/views/login.html',
controller: 'LoginAdminCtrl',
})
.state('admin_licenses', {
url: '/admin/licenses',
......
......@@ -25,9 +25,7 @@
<img ng-src="{{ croppedDataUrl }}" />
</div>
<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 class="form-group">
<span class="progress" ng-show="progress > 0">
......@@ -40,6 +38,11 @@
</div> <!-- /modal-body -->
<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>
......@@ -6,11 +6,11 @@
<h4 class="modal-title" id="myModalLabel" translate>add_expression</h4>
</div>
<div class="modal-body">
<form ng-submit="save()">
<div id="add_label" class="input-group">
<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">
<button class="btn btn-success" type="submit" translate>save</button>
</span>
......@@ -19,4 +19,4 @@
</div>
<!-- End modal-body -->
</div>
\ No newline at end of file
</div>
......@@ -5,7 +5,7 @@
//-----------------------
// 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
var user = JSON.parse($window.sessionStorage.user);
......@@ -32,4 +32,62 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl($scope
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 @@
</a>
</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>
{{ 'own_pictos' | translate }}
</a>
......
......@@ -26,7 +26,7 @@
</div>
<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>
......
......@@ -3,12 +3,45 @@
//----------------------
// Translate Controller
//----------------------
dashboardControllers.controller('TranslateController', function($translate, $scope, vcRecaptchaService) {
dashboardControllers.controller('TranslateController', function(
$translate,
$scope,
$window,
$http,
config,
ngToast,
vcRecaptchaService
) {
$scope.changeLanguage = function (langKey) {
//Translate update
$translate.use(langKey);
//Scope update
$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)
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) {
'assets/scripts/modules/login/controllers/login.js',
'assets/scripts/modules/login/controllers/login_setting_password.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/licenses.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