Commit 2c9a01b0 by Arturo Montejo Ráez

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

parents e1b6287a 252741c0
......@@ -50,6 +50,9 @@ public class Picto extends Img {
public static String EXPRESSION = "expression";
public static String MIRROR = "mirror";
public static String LEGEND = "legend";
public static String URI_SOUND = "uri_sound";
public static String USER_AVATAR = "user_avatar";
public static String ASSOCIATED_PERSON = "associated_person";
}
......@@ -88,7 +91,7 @@ public class Picto extends Img {
Log.e(LOG_TAG,e.getMessage());
}
}
public Picto(int id, String url, String translation, int cat, int row, int column, int freeRow, int freeColumn, int stupicto_id) throws JSONException {
public Picto(int id, String url, String translation, int cat, int row, int column, int freeRow, int freeColumn, int stupicto_id, String uri_sound, String user_avatar, String associated_person) throws JSONException {
this(id, url, new JSONObject()
.put(JSON_ATTTRS.CATEGORY, cat)
.put(JSON_ATTTRS.COLUMN, column)
......@@ -98,7 +101,11 @@ public class Picto extends Img {
.put(JSON_ATTTRS.STATUS, JSON_ATTTR_STATUS_VALUES.ENABLED)
.put(JSON_ATTTRS.LEGEND,JSON_ATTTR_LEGEND_VALUES.NONE)
.put(JSON_ATTTRS.STUPICTO_ID,stupicto_id)
.put(JSON_ATTTRS.EXPRESSION,translation));
.put(JSON_ATTTRS.EXPRESSION,translation)
.put(JSON_ATTTRS.URI_SOUND,uri_sound)
.put(JSON_ATTTRS.USER_AVATAR,user_avatar)
.put(JSON_ATTTRS.ASSOCIATED_PERSON,associated_person)
);
}
public Picto(int id, String url,String translation, String attributes) throws JSONException {
this(id, url, new JSONObject(attributes).put(JSON_ATTTRS.EXPRESSION,translation));
......@@ -106,7 +113,7 @@ public class Picto extends Img {
public Picto(int id, String url, JSONObject attributes) {
super(id,url,Img.VOCABULARY);;
super(id,url,Img.VOCABULARY);
this.attributes = attributes;
try {
if (this.attributes.get(JSON_ATTTRS.CATEGORY)==null)
......@@ -296,6 +303,20 @@ public class Picto extends Img {
/**
*
* @return the associated person of a picto
*/
public String get_associated_person() {
String ass_person = null;
try {
ass_person = this.attributes.getString(JSON_ATTTRS.ASSOCIATED_PERSON);
} catch (JSONException e) {
e.printStackTrace();
}
return ass_person;
}
/**
*
* @return the row of the picto
*/
public int get_row() {
......@@ -341,7 +362,26 @@ public class Picto extends Img {
}
}
/**
*
* @return the uri of associated sound of the picto
*/
public String getUriSound(){
try {
return this.attributes.getString(JSON_ATTTRS.URI_SOUND);
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
*
* @return the associated user avatar of the picto
*/
public String getUserAvatar(){
return this.attributes.optString(JSON_ATTTRS.USER_AVATAR);
}
/**
* A picto is a category iif:
......
......@@ -44,6 +44,7 @@ public class User {
public static String READ="read";
public static String HIGHLIGHT="highlight";
}
private String supervisors;
private Img img_stu;
private String nickname_stu, pwd_stu, name_stu, surname_stu, gender_stu, lang_stu;
private JSONObject attributes_stu;
......@@ -266,7 +267,13 @@ public class User {
}
}
public String get_Supervisors(){
return this.supervisors;
}
public void set_Supervisors(String newSup) {
this.supervisors = newSup;
}
/**
*
* @return delivery method
......
......@@ -301,6 +301,13 @@ public class Vocabulary implements Iterable<Picto> {
return picto;
}
/**
*
* @param pic_cat Category id of the picto
* @param pic_id Id image of the picto
* @description Obtain the id of picto with "picto.get_id()"
* @return
*/
public Picto get_picto(int pic_cat, int pic_id) {
Picto picto=null;
LinkedList<Picto> pictos_cat=this.pictos.get(pic_cat);
......@@ -308,6 +315,7 @@ public class Vocabulary implements Iterable<Picto> {
if (pictos_cat.get(i).get_id()==pic_id) picto=pictos_cat.get(i);
return picto;
}
/**
* It removes de given pic from the user collection
* @param pic_id
......@@ -399,7 +407,7 @@ public class Vocabulary implements Iterable<Picto> {
/*
* It saves locally a new picto obtained from the PCB
*/
public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y, final iLocalPicto listener) {
public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y,String uri_sound,String user_avatar,String associated_person, final iLocalPicto listener) {
Picto prev_picto=find_picto(cat, coord_x,coord_y); //¿estamos reemplazanddo un picto que ya existe?
......@@ -411,7 +419,7 @@ public class Vocabulary implements Iterable<Picto> {
int id=PCBcontext.getDevice().getNextLocalPictoID();
try {
final Picto picto = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y, prev_picto!=null ? prev_picto.get_stupicto_id() : Picto.STUPICTO_NULL);
final Picto picto = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y,prev_picto!=null ? prev_picto.get_stupicto_id() : Picto.STUPICTO_NULL,uri_sound,user_avatar,associated_person);
addPicto(picto, ImgDownloader.tsource.local, new ImgDownloader.iImgDownloaderListener() {
@Override
public void loadComplete() {
......
......@@ -50,7 +50,7 @@ public class PictoUploader {
bmp=img.get_bitmap(PCBcontext.getContext());
Log.i(LOG_TAG, "Uploading Picto img " + img.file_name() + " from " + img.get_type() + "- Size:" + bmp.getWidth() + " " + bmp.getHeight());
/*Log.i(LOG_TAG, "Uploading Picto img " + img.file_name() + " from " + img.get_type() + "- Size:" + bmp.getWidth() + " " + bmp.getHeight());*/
File file = img.file(PCBcontext.getContext());
......
......@@ -26,7 +26,11 @@ import static android.graphics.Color.argb;
public class PictoMenu {
private static final String LOG_TAG = PictoMenu.class.getName();
public static final String ID_PICTO_IMAGE = "id_imagen_picto";
public static final String IS_EDIT = "is_edit";
public static final String PATH = "pathImage";
public static final String IMAGE_PICTO = "imagePicto";
PictogramActivity activity;
//Variables used on the picto menu (only supervisors)
......@@ -50,9 +54,8 @@ public class PictoMenu {
*
* @param row
* @param col
* @param expression
*/
public void createMenuForNewPicto(final int row, final int col, final int cat, final String expression) {
public void createMenuForNewPicto(final int row, final int col, final int cat) {
ll = new RelativeLayout(PCBcontext.getContext());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
......@@ -75,16 +78,14 @@ public class PictoMenu {
PieMenu.setCenterCircle(new Close());
PieMenu.addMenuEntry(new newPickFromCamera(row,col,cat,expression));
PieMenu.addMenuEntry(new newPickFromGallery(row,col,cat,expression));
PieMenu.addMenuEntry(new newPickFromCamera(row,col,cat/*,expression*/));
PieMenu.addMenuEntry(new newPickFromGallery(row,col,cat/*,expression*/));
ll.addView(PieMenu);
}
public void addPicto(int row, int col, int cat, String expression, int source) {
activity.getIntent().putExtra(Picto.JSON_ATTTRS.EXPRESSION, expression);
public void addPicto(int row, int col, int cat, int source) {
//Enviar al PictogramActivity los datos necesarios para crear el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
activity.getIntent().putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
......@@ -95,7 +96,7 @@ public class PictoMenu {
activity.getIntent().putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col);
}
if (source== 0) { //Pick from camera
if (source == 0) { //Pick from camera
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
activity.startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
} else { //Pick from file
......@@ -107,10 +108,10 @@ public class PictoMenu {
}
public void setPicto(int row, int col, int cat, String expression, Bitmap bitmap){
public void setPicto(int row, int col, int cat, Bitmap bitmap, int id_picto){
Intent intent = new Intent(activity, EditPictoActivity.class);
intent.putExtra(ID_PICTO_IMAGE,id_picto);
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, expression);
//Enviar al PictogramActivity los datos necesarios para editar el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
......@@ -121,24 +122,11 @@ public class PictoMenu {
intent.putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col);
}
if(bitmap!=null) {
Point size= GUITools.getScreenSize(activity);
float bWidth = bitmap.getWidth();
float bHeight = bitmap.getHeight();
float factorX=size.x*0.7f/bWidth;
float factorY=size.y*0.7f/bHeight;
float factor= factorY>factorX ? factorX : factorY;
bWidth=bWidth*factor;
bHeight=bHeight*factor;
Bitmap rescaled = Bitmap.createScaledBitmap(bitmap,(int) bWidth, (int) bHeight, true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra(EditPictoActivity.IMAGE_PICTO, byteArray);
}
intent.putExtra("tipo",true);
intent.putExtra(IMAGE_PICTO, byteArray);
intent.putExtra(IS_EDIT,true);
activity.startActivityForResult(intent,EditPictoActivity.EDIT_PICTO_REQUEST);
}
......@@ -297,67 +285,22 @@ public class PictoMenu {
ll.removeAllViewsInLayout();
try {
setPicto(p.get_row(),p.get_column(),p.get_category(),p.get_translation(),p.get_bitmap(PCBcontext.getContext()));
setPicto(p.get_row(),p.get_column(),p.get_category(),p.get_bitmap(PCBcontext.getContext()),p.get_id());
} catch (IOException e) {
e.printStackTrace();
}
//ll.getChildAt(1).setX(ll.getChildAt(1).getX() + 30);
//children = new ArrayList<>(Arrays.asList(new PickFromCamera(p),new PickFromGallery(p)));
}
public void menuDisabled(){
//ll.getChildAt(1).setX(ll.getChildAt(1).getX() - 30);
}
}
/*public class PickFromCamera implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public PickFromCamera(Picto picto){
p = picto;
}
public String getName() { return "editText"; }
public String getLabel() { return null; }
public int getIcon() { return R.drawable.camera; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated()
{
ll.setVisibility(View.GONE);
ll.removeAllViewsInLayout();
addPicto(p.get_row(),p.get_column(),p.get_category(),p.get_translation(),0);
}
public void menuDisabled(){}
}
public class PickFromGallery implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public PickFromGallery(Picto picto){
p = picto;
}
public String getName() { return "editImage"; }
public String getLabel() { return null; }
public int getIcon() { return R.drawable.gallery; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated()
{
ll.setVisibility(View.GONE);
ll.removeAllViewsInLayout();
addPicto(p.get_row(),p.get_column(),p.get_category(),p.get_translation(),1);
}
public void menuDisabled(){}
}*/
public class newPickFromCamera implements RadialMenuWidget.RadialMenuEntry
{
int row,col,cat;
String expression;
public newPickFromCamera(int row, int col,int cat,String expression){
public newPickFromCamera(int row, int col,int cat){
this.row = row;
this.col = col;
this.cat = cat;
this.expression = expression;
}
public String getName() { return ""; }
public String getLabel() { return null; }
......@@ -368,7 +311,7 @@ public class PictoMenu {
ll.setVisibility(View.GONE);
ll.removeAllViewsInLayout();
addPicto(row,col,cat,expression,0);
addPicto(row,col,cat,0);
}
public void menuDisabled(){}
}
......@@ -376,12 +319,10 @@ public class PictoMenu {
public class newPickFromGallery implements RadialMenuWidget.RadialMenuEntry
{
int row,col,cat;
String expression;
public newPickFromGallery(int row, int col,int cat,String expression){
public newPickFromGallery(int row, int col,int cat){
this.row = row;
this.col = col;
this.cat = cat;
this.expression = expression;
}
public String getName() { return ""; }
public String getLabel() { return null; }
......@@ -391,7 +332,7 @@ public class PictoMenu {
{
ll.setVisibility(View.GONE);
ll.removeAllViewsInLayout();
addPicto(row,col,cat,expression,1);
addPicto(row,col,cat,1);
}
public void menuDisabled(){}
}
......
......@@ -869,7 +869,7 @@ 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 (getCurrentCategory() != null || !PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
new PictoMenu(PictogramActivity.this).createMenuForNewPicto(position % maxColumns, (int) (position / maxColumns), currentCategory.get_id(),null);
new PictoMenu(PictogramActivity.this).createMenuForNewPicto(position % maxColumns, (int) (position / maxColumns), currentCategory.get_id());
} else
Toast.makeText(PictogramActivity.this, PictogramActivity.this.getResources().getString(R.string.notNewCats), Toast.LENGTH_SHORT).show();
......@@ -1127,7 +1127,7 @@ protected void showOnlyTape(boolean onlyTape) {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap imagen = null;
Bitmap imagen;
switch(requestCode) {
case CAMERA_PIC_REQUEST: //Captura de foto
if (data != null && resultCode==RESULT_OK) {
......@@ -1149,18 +1149,24 @@ protected void showOnlyTape(boolean onlyTape) {
break;
case EditPictoActivity.EDIT_PICTO_REQUEST:
if (resultCode == RESULT_OK) {
boolean edit = data.getBooleanExtra("tipo",false);
boolean edit = data.getBooleanExtra(PictoMenu.IS_EDIT,false);
int row = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.ROW) : getIntent().getIntExtra(Picto.JSON_ATTTRS.ROW, -1);
int col = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.COLUMN) : getIntent().getIntExtra(Picto.JSON_ATTTRS.COLUMN, -1);
int freeRow = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_ROW) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_ROW, -1);
int freeColumn = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_COLUMN) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
String uri_sound = edit ? data.getExtras().getString(Picto.JSON_ATTTRS.URI_SOUND) : getIntent().getStringExtra(Picto.JSON_ATTTRS.URI_SOUND);
String associated_person = edit ? data.getExtras().getString(Picto.JSON_ATTTRS.ASSOCIATED_PERSON) : getIntent().getStringExtra(Picto.JSON_ATTTRS.ASSOCIATED_PERSON);
int cat = edit ? data.getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1) : getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1);
String path = data.getExtras().getString(EditPictoActivity.PATH);
String path = data.getExtras().getString(PictoMenu.PATH);
String legend = data.getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend);
Log.i(EditPictoActivity.DEBUG_MESSAGE,"Antes de chooseText...DATOS--> ASS_PERSON: "+associated_person+"..URI_SOUND: "+uri_sound+"..PATH_IMAGE: "+path+"..EXPRESION: "+legend);
//TODO: COGER URI DEL SONIDO,EL USER AVATAR Y LA PERSONA ASOCIADA AL PICTO
chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend, uri_sound, null, associated_person);
refresh();
}
break;
......@@ -1172,7 +1178,7 @@ protected void showOnlyTape(boolean onlyTape) {
* función para la edición de un texto asociado a una nueva imagen y guardar el nuevo picto
*/
public void chooseTextAndSavePicto(final String selectedImagePath, final int row, final int col, final int freeRow, final int freeColumn,
final int category, final String legend) {
final int category, final String legend,final String uri_sound,final String user_avatar, String associated_person) {
// Set up the buttons
int cat = category != -1 ? category : Picto.NO_CATEGORY;
......@@ -1186,6 +1192,9 @@ protected void showOnlyTape(boolean onlyTape) {
col,
freeRow,
freeColumn,
uri_sound,
user_avatar,
associated_person,
new iLocalPicto() {
@Override
public void saved(Picto localPicto) {
......@@ -1207,26 +1216,12 @@ protected void showOnlyTape(boolean onlyTape) {
Intent intent = new Intent(this, EditPictoActivity.class);
if(image!=null) {
Point size=GUITools.getScreenSize(this);
float bWidth = image.getWidth();
float bHeight = image.getHeight();
float factorX=size.x*0.7f/bWidth;
float factorY=size.y*0.7f/bHeight;
float factor= factorY>factorX ? factorX : factorY;
bWidth=bWidth*factor;
bHeight=bHeight*factor;
Bitmap rescaled = Bitmap.createScaledBitmap(image,(int) bWidth, (int) bHeight, true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
image.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra(EditPictoActivity.IMAGE_PICTO, byteArray);
intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray);
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, getIntent().getStringExtra(Picto.JSON_ATTTRS.EXPRESSION));
startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST);
}
}
}
......@@ -2,52 +2,64 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper;
import android.Manifest;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.media.MediaActionSound;
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.grammar.Vocabulary;
import com.yottacode.pictogram.grammar.iLocalPicto;
import com.yottacode.pictogram.net.PictoUploader;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.gui.login.MainActivity;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictoMenu;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
import org.json.JSONException;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Random;
import pl.droidsonroids.gif.GifTextView;
import static java.lang.Thread.sleep;
/**
......@@ -56,14 +68,20 @@ import static java.lang.Thread.sleep;
public class EditPictoActivity extends Activity {
Picto p;
private boolean editar;
Random nRandom = new Random();
int pathNumber;
//Sonidos de sistema para grabar
final MediaActionSound recordSoundOn = new MediaActionSound();
final MediaActionSound recordSoundOff = new MediaActionSound();
private static final int CAMERA_PIC_REQUEST = 1;
private static final int GALLERY_PIC_REQUEST = 2;
private static final String DEBUG_MESSAGE = "Pruebas";
public static final String DEBUG_MESSAGE = "TAG_PRUEBAS";
public static final int EDIT_PICTO_REQUEST = 2288;
public static final int FINISH_EDIT = 2500;
//Botones Final/////////////////////////////////////////////////////////////////////
Button okButton;
......@@ -77,16 +95,26 @@ public class EditPictoActivity extends Activity {
BotonCircular camara;
BotonCircular galeria;
public static final String PATH = "pathImage";
public static final String IMAGE_PICTO = "imagePicto";
private static final String LOG_PATH = EditPictoActivity.class.getName();
//For Legend//////////////////////////////////////////////////////////////////////////
EditText legend;
//For Associated Supervisors/////////////////////////////////////////////////////////
Button desplegableSupervisores;
TextView supAsociado;
private ListView mDrawerList;
private ArrayAdapter<String> mAdapter;
private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
//For Audio///////////////////////////////////////////////////////////////////////////
private static final int REQUEST_RECORD_AUDIO_PERMISSION = 200;
private static String mFileName = null;
private static String previewAudioPath = null;
private String dirImagePath = null;
private String dirAudioPath = null;
private MediaRecorder mRecorder = null;
private MediaPlayer mPlayer = null;
......@@ -100,18 +128,20 @@ public class EditPictoActivity extends Activity {
SeekBar barraReproducir;
TextView textoTTotal;
TextView textoTGrabacion;
LinearLayout layoutPreview;
LinearLayout layoutGrabacion;
RecordTask tareaGrabacion;
PlayTask tareaReproduccion;
//boolean grabando;
boolean hayGrabacion;
boolean reproduciendo;
int tiempoGrabado;
int tiempoReproducir;
int tiempoTotal;
int id_pic;
// Requesting permission to RECORD_AUDIO
private boolean permissionToRecordAccepted = false;
private String [] permissions = {Manifest.permission.RECORD_AUDIO};
......@@ -149,8 +179,11 @@ public class EditPictoActivity extends Activity {
tiempoTotal = tiempoGrabado-1;
barraReproducir.setMax(tiempoTotal);
botonGrabar.PhidePressedRing();
Log.i(DEBUG_MESSAGE,"Fin Grabacion.."+tiempoGrabado);
if(tiempoGrabado>1) hayGrabacion = true ;
else hayGrabacion = false;
reiniciarGrabacion();
Log.i(DEBUG_MESSAGE,"Fin Grabacion..");
}
}
......@@ -190,58 +223,186 @@ public class EditPictoActivity extends Activity {
// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.edit_picto_layout);
Log.i(DEBUG_MESSAGE,"EDITAR ABIERTO");
//Persmisos para grabar audio
ActivityCompat.requestPermissions(this, permissions, REQUEST_RECORD_AUDIO_PERMISSION);
//Editar la lista desplegable de supervisores asociados
mDrawerList = (ListView)findViewById(R.id.navList);
/**Obtener la lista de supervisores y aplicarle formato*/
Log.i(DEBUG_MESSAGE,"Usuario: "+ PCBcontext.getPcbdb().getCurrentUser().get_name_stu());
String supervisors = PCBcontext.getPcbdb().getCurrentUser().get_Supervisors();
Log.i(DEBUG_MESSAGE,"Supervisores: "+ supervisors);
ArrayList<String> supervisores = new ArrayList<>();
if(supervisors != null) {
String[] separated = supervisors.split(";");
for (String supervisor : separated) {
String[] detalles = supervisor.split(",");
supervisores.add(detalles[0] + "\n" + detalles[1]);
}
}else
Log.i(DEBUG_MESSAGE,"No tiene supervisores...");
mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, supervisores);
mDrawerList.setAdapter(mAdapter);
mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.string.drawer_open, R.string.drawer_close) {
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
invalidateOptionsMenu();
}
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
invalidateOptionsMenu();
}
};
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mDrawerToggle);
//Aplicar medidas a los elementos de la vista
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
LinearLayout ll = (LinearLayout) findViewById(R.id.image_layout);
Log.i("DETALLES", "Tam menu imagen: " + ll.getLayoutParams().width);
ll.getLayoutParams().width = (int) (metrics.widthPixels * 0.65) - (int) getResources().getDimension(R.dimen.activity_vertical_margin) * 2;
Log.i("DETALLES", "Tam menu imagen: " + ll.getLayoutParams().width);
ll.requestLayout();
FrameLayout fl = (FrameLayout) findViewById(R.id.legend_menu);
Log.i("DETALLES", "Tam menu leyenda: " + fl.getLayoutParams().width);
fl.getLayoutParams().width = (int) (metrics.widthPixels * 0.25) - (int) getResources().getDimension(R.dimen.activity_vertical_margin);
Log.i("DETALLES", "Tam menu leyenda: " + fl.getLayoutParams().width);
fl.requestLayout();
//Definir rutas de almacenado de imagen y audio
dirImagePath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DCIM;
dirImagePath += "/PictoImages";
File fileImage = new File(dirImagePath);
if (!fileImage.exists()) {
fileImage.mkdirs();
}
dirAudioPath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_MUSIC;
dirAudioPath += "/PictoAudio";
File fileAudio = new File(dirAudioPath);
if(!fileAudio.exists()){
fileAudio.mkdirs();
}
previewAudioPath = dirAudioPath+File.separator+"test.3gp";
// Initialize Views.
titulo = (TextView) findViewById(R.id.crop_title);
cropImageView = (CropImageView) findViewById(R.id.CropImageView);
legend = (EditText) findViewById(R.id.edtLegend);
okButton = (Button) findViewById(R.id.okButton);
cancelButton = (Button) findViewById(R.id.cancelButton);
String transcription = getIntent().getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
desplegableSupervisores = (Button) findViewById(R.id.botonDesplegable);
supAsociado = (TextView) findViewById(R.id.sup_actual);
botonGrabar = (BotonCircular) findViewById(R.id.botonGrabar);
botonReproducir = (BotonCircular) findViewById(R.id.reproducir);
botonBorrar = (BotonCircular) findViewById(R.id.botonBorrar);
camara = (BotonCircular) findViewById(R.id.camara);
galeria = (BotonCircular) findViewById(R.id.galeria);
gifRecord = (GifTextView) findViewById(R.id.recordImage);
barraReproducir = (SeekBar) findViewById(R.id.barraReproducir);
textoTTotal = (TextView) findViewById(R.id.tiempoTotal);
textoTGrabacion = (TextView) findViewById(R.id.tiempoActual);
layoutPreview = (LinearLayout) findViewById(R.id.layoutPreview);
layoutGrabacion = (LinearLayout) findViewById(R.id.layout_record);
botonReproducir.setEnabled(false);
layoutPreview.setVisibility(View.INVISIBLE);
hayGrabacion = false;
reproduciendo = false;
tiempoGrabado = 0;
tiempoReproducir = 0;
tiempoTotal = 0;
//String transcription = getIntent().getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
cropImageView.setFixedAspectRatio(true);
cropImageView.setGuidelines(2);
//cropImageView.setAspectRatio(cropImageView.getWidth(),cropImageView.getHeight());
if (transcription != null && transcription.length() > 0)
legend.setText(transcription);
//Para ver si la vista es para editar uno ya existente o para añadir uno nuevo
editar = getIntent().getBooleanExtra(PictoMenu.IS_EDIT,false);
titulo.setText(editar ? R.string.titleCropperEdit : R.string.titleCropperNew);
//Obtener el picto a editar
if(editar){
p = PCBcontext.getVocabulary().get_picto(getIntent().getExtras().getInt(Picto.JSON_ATTTRS.CATEGORY),getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE));
legend.setText(p.get_translation());
supAsociado.setText(p.get_associated_person());
}
legend.setHorizontallyScrolling(false);
legend.setMaxLines(1);
legend.setSingleLine(true);
editar = getIntent().getBooleanExtra("tipo",false);
titulo.setText(editar ? R.string.titleCropperEdit : R.string.titleCropperNew);
//Obtener imagen del intent
byte[] byteArray = getIntent().getByteArrayExtra(EditPictoActivity.IMAGE_PICTO);
Bitmap imagePicto = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
byte[] byteArray = getIntent().getByteArrayExtra(PictoMenu.IMAGE_PICTO);
Bitmap imagePicto = scale_image(BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length));
cropImageView.setAspectRatio(editar ? imagePicto.getWidth() : 4,editar ? imagePicto.getHeight() : 3); //Si es editar un picto la ventana de recorte mantiene el tamaño de la imagen, sino 4:3
cropImageView.setImageBitmap(imagePicto);
cropImageView.setMaxWidth(imagePicto.getWidth());
cropImageView.setMaxHeight(imagePicto.getHeight());
if (transcription != null && transcription.length() > 0)
legend.setText(transcription);
/*if (transcription != null && transcription.length() > 0)
legend.setText(transcription);*/
editar = getIntent().getBooleanExtra("tipo",false);
titulo.setText(editar ? R.string.titleCropperEdit : R.string.titleCropperNew);
//TODO: Aqui comprobar si ya hay grabación
//if (hayGrabacionAnterior){
layoutGrabacion.setVisibility(View.VISIBLE);
layoutPreview.setVisibility(View.GONE);
//}else{ Cargar el audio en el mediaPlayer
//layoutGrabacion.setVisibility(View.GONE);
//layoutPreview.setVisibility(View.VISIBLE);
//}
pathNumber = nRandom.nextInt();
desplegableSupervisores.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT))
mDrawerLayout.closeDrawer(Gravity.RIGHT);
else
mDrawerLayout.openDrawer(Gravity.RIGHT);
}
});
// Set the list's click listener
mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String[] assocciated_person = mDrawerList.getAdapter().getItem(position).toString().split("\n");
supAsociado.setText(assocciated_person[1]);
mDrawerLayout.closeDrawer(Gravity.RIGHT);
//Log.i(DEBUG_MESSAGE, "Supervisor Asociado Actual: " + p.get_associated_person());
//p.alter_associated_person(assocciated_person[1]); //cambiar el la persona asociada
//Log.i(DEBUG_MESSAGE,"String: "+assocciated_person[1]);
//Log.i(DEBUG_MESSAGE, "Supervisor Asociado Nuevo: " + p.get_associated_person());
}
});
//Gestion de botones
okButton.setOnClickListener(new View.OnClickListener() {
......@@ -249,27 +410,69 @@ public class EditPictoActivity extends Activity {
public void onClick(View v) {
if (legend.getText().toString().trim().length() > 0) {
final Bitmap croppedImage = cropImageView.getCroppedImage();
//Guardar imagen en galeria y obtener la ruta
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
croppedImage.compress(Bitmap.CompressFormat.PNG, 100, bytes);
String title = getResources().getString(R.string.app_name) + ' ' + legend.getText().toString();
String path = MediaStore.Images.Media.insertImage(getContentResolver(), croppedImage, title, null);
path = getRealPathFromURI(Uri.parse(path));
Log.i(LOG_PATH, " New image " + title + " saved at " + path);
String filepath = null;
String audioPath = null;
try {
id_pic = getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE);
filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_pic + ".png"
: dirImagePath + File.separator + legend.getText().toString() + "_new_" + pathNumber+ ".png";
File imageFile = new File(filepath);
if(!editar) { //Si es añadir uno nuevo comprobar que el random no existe ya en el path
while (imageFile.exists()) {
pathNumber = nRandom.nextInt();
}
filepath = dirImagePath + File.separator + legend.getText().toString() + "_new_" + pathNumber+ ".png";
}
FileOutputStream outputStream = new FileOutputStream(imageFile);
Bitmap bitmap = Bitmap.createBitmap(cropImageView.getCroppedImage());
bitmap.compress(Bitmap.CompressFormat.PNG, 90, outputStream);
outputStream.flush();
outputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if(hayGrabacion) { //Si ha grabado algo -> Ir a renombrarlo
File file = new File(previewAudioPath);
if (file.exists()) {
File from = new File(previewAudioPath);
File to = new File(editar ? dirAudioPath + File.separator + legend.getText().toString() + "_" + id_pic + "_audio.3gp" :
dirAudioPath + File.separator + legend.getText().toString() + "_new_" + pathNumber + "_audio.3gp");
if (from.exists()){
from.renameTo(to);
Log.i(DEBUG_MESSAGE,to.getPath().toString());
audioPath = to.getPath().toString();
}
}
}
Intent intent = getIntent(); //Mandar a pictogram activity el path y el texto de la imagen
intent.putExtra(PATH, path);
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString());
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY,getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra("tipo",editar); //Para saber despues si estas editando o añadiendo nuevo y coger los datos de intent o de data en OnActivityResult
intent.putExtra(PictoMenu.IS_EDIT, editar); //Para saber despues si estas editando o añadiendo nuevo y coger los datos de intent o de data en OnActivityResult
intent.putExtra(PictoMenu.PATH, filepath); //Mandar Path imagen
intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,audioPath); //Mandar el path del audio
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString()); //Mandar expresion nueva
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra(Picto.JSON_ATTTRS.ASSOCIATED_PERSON, supAsociado.getText());
setResult(RESULT_OK, intent);
cropImageView.setImageBitmap(croppedImage);
finish(); //Termina la actividad de editar
} else
Toast.makeText(getBaseContext(), R.string.crop_TextRequired, Toast.LENGTH_LONG).show();
}
});
......@@ -282,59 +485,29 @@ public class EditPictoActivity extends Activity {
}
});
// Record to the external cache directory for visibility
mFileName = getFilesDir().getPath();
mFileName += "/audiorecordtest.3gp";
ContentValues values = new ContentValues(3);
values.put(MediaStore.MediaColumns.TITLE, mFileName);
ActivityCompat.requestPermissions(this, permissions, REQUEST_RECORD_AUDIO_PERMISSION);
//Initialize elements and variables
botonGrabar = (BotonCircular) findViewById(R.id.botonGrabar);
botonReproducir = (BotonCircular) findViewById(R.id.reproducir);
botonBorrar = (BotonCircular) findViewById(R.id.botonBorrar);
camara = (BotonCircular) findViewById(R.id.camara);
galeria = (BotonCircular) findViewById(R.id.galeria);
gifRecord = (GifTextView) findViewById(R.id.recordImage);
barraReproducir = (SeekBar) findViewById(R.id.barraReproducir);
textoTTotal = (TextView) findViewById(R.id.tiempoTotal);
textoTGrabacion = (TextView) findViewById(R.id.tiempoActual);
layoutPreview = (LinearLayout) findViewById(R.id.layoutPreview);
layoutGrabacion = (LinearLayout) findViewById(R.id.layout_record);
botonReproducir.setEnabled(false);
layoutPreview.setVisibility(View.INVISIBLE);
reproduciendo = false;
tiempoGrabado = 0;
tiempoReproducir = 0;
tiempoTotal = 0;
//TODO: Aqui comprobar si ya hay grabación
//if (hayGrabacion){
layoutGrabacion.setVisibility(View.VISIBLE);
layoutPreview.setVisibility(View.GONE);
//}else{ Cargar el audio en el mediaPlayer
//layoutGrabacion.setVisibility(View.GONE);
//layoutPreview.setVisibility(View.VISIBLE);
//}
botonGrabar.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
recordSoundOn.play(MediaActionSound.START_VIDEO_RECORDING);
tareaGrabacion = (RecordTask) new RecordTask().execute(tiempoGrabado);
startRecording();
gifRecord.setBackgroundResource(R.drawable.record_animation);
try { //Para que no capture el sonido del sistema
sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
startRecording();
Log.i(DEBUG_MESSAGE,"Grabando..");
return true;
case MotionEvent.ACTION_UP:
gifRecord.setBackgroundResource(R.color.white);
tareaGrabacion.cancel(true);
recordSoundOff.play(MediaActionSound.FOCUS_COMPLETE);
return true;
}
return false;
......@@ -424,7 +597,7 @@ public class EditPictoActivity extends Activity {
private void startPlaying() {
mPlayer = new MediaPlayer();
try {
mPlayer.setDataSource(mFileName);
mPlayer.setDataSource(previewAudioPath);
mPlayer.prepare();
mPlayer.start();
} catch (IOException e) {
......@@ -441,9 +614,9 @@ public class EditPictoActivity extends Activity {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
Log.i(DEBUG_MESSAGE,mFileName);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile(previewAudioPath);
try {
mRecorder.prepare();
......@@ -466,6 +639,7 @@ public class EditPictoActivity extends Activity {
private void reiniciarGrabacion(){
tiempoGrabado = 0;
textoTGrabacion.setText("00:00 | 00:10");
//hayGrabacion = false;
}
private void reiniciarReproducción(){
......@@ -494,6 +668,8 @@ public class EditPictoActivity extends Activity {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT))
mDrawerLayout.closeDrawer(Gravity.RIGHT);
finish();
setResult(RESULT_CANCELED, getIntent());
return true;
......@@ -504,32 +680,19 @@ public class EditPictoActivity extends Activity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//int cat = getIntent().getIntExtra("cat", -1);
Bitmap imagen;
Bitmap imagen = null;
Bitmap rescaled = null;
switch(requestCode) {
case CAMERA_PIC_REQUEST: //Captura de foto
if (data != null && resultCode==RESULT_OK) {
imagen = (Bitmap) data.getExtras().get("data");
if(imagen!=null) {
Point size= GUITools.getScreenSize(EditPictoActivity.this);
float bWidth = imagen.getWidth();
float bHeight = imagen.getHeight();
float factorX=size.x*0.7f/bWidth;
float factorY=size.y*0.7f/bHeight;
float factor= factorY>factorX ? factorX : factorY;
bWidth=bWidth*factor;
bHeight=bHeight*factor;
rescaled = Bitmap.createScaledBitmap(imagen,(int) bWidth, (int) bHeight, true);
Bitmap rescaled = scale_image(imagen);
cropImageView.setImageBitmap(rescaled);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
getIntent().putExtra(EditPictoActivity.IMAGE_PICTO, byteArray);
}
cropImageView.setImageBitmap(rescaled);
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);
}
break;
......@@ -542,6 +705,22 @@ public class EditPictoActivity extends Activity {
} catch (IOException e) {
e.printStackTrace();
}
Bitmap rescaled = scale_image(bitmap);
cropImageView.setImageBitmap(rescaled);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);
}
break;
}
}
public Bitmap scale_image(Bitmap bitmap){
Bitmap rescaled = null;
if(bitmap!=null) {
Point size= GUITools.getScreenSize(EditPictoActivity.this);
float bWidth = bitmap.getWidth();
......@@ -554,15 +733,7 @@ public class EditPictoActivity extends Activity {
bHeight=bHeight*factor;
rescaled = Bitmap.createScaledBitmap(bitmap,(int) bWidth, (int) bHeight, true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
getIntent().putExtra(EditPictoActivity.IMAGE_PICTO, byteArray);
}
cropImageView.setImageBitmap(rescaled);
}
break;
}
return rescaled;
}
}
......@@ -18,6 +18,7 @@ import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity;
import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
......@@ -27,6 +28,8 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
/**
......@@ -80,8 +83,10 @@ public class StudentFragmentGrid extends Fragment{
PCBcontext.set_user(currentUser, null, null);
Intent pictogramActivity = new Intent(getActivity(), PictogramActivity.class);
startActivity(pictogramActivity);
} else
} else {
new_user(i);
download_supervisors(PCBcontext.getPcbdb().getCurrentUser().get_id_stu());
}
}
private void new_user(int i) {
......@@ -198,6 +203,47 @@ public class StudentFragmentGrid extends Fragment{
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs);
}
private void download_supervisors(int stu_id) {
String token = getActivity().getIntent().getExtras().getString("token");
RestapiWrapper wrapper = PCBcontext.getRestapiWrapper();
wrapper.setToken(token);
String operation = "stu/" + stu_id + "/supervisors";
wrapper.ask(operation, new RestapiWrapper.iRestapiListener() {
@Override
public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage());
GUITools.show_alert(getActivity(), R.string.loginErrorTxt, getString(R.string.serverError), new GUITools.iOKListener() {
@Override
public void ok() {
PCBcontext.getNetService().restart_app(false);
}
});
}
@Override
public void preExecute() {
}
@Override
public void result(JSONArray supervisors) {
String supervisorsFormat = "";
for (int i=0;i<supervisors.length();i++) {
JSONObject supervisor;
try {
supervisor = supervisors.getJSONObject(i);
supervisorsFormat += supervisor.get("name") +" " + supervisor.get("surname") + "," + supervisor.get("email") + ";";
} catch (JSONException e) {
e.printStackTrace();
}
}
PCBcontext.getPcbdb().getCurrentUser().set_Supervisors(supervisorsFormat);
}
@Override
public void result(JSONObject result) {
}
});
}
private void download_students(int sup_id ) {
String token = getActivity().getIntent().getExtras().getString("token");
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<android.support.v4.widget.DrawerLayout
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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
......@@ -103,6 +106,38 @@
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textAssociated"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Asociar a:"
android:textColor="@color/gray"
android:textSize="20sp" />
<Button
android:id="@+id/botonDesplegable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ver" />
</LinearLayout>
<TextView
android:id="@+id/sup_actual"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="18sp" />
<TextView
android:id="@+id/textLegend"
android:layout_width="match_parent"
......@@ -118,6 +153,7 @@
android:layout_height="wrap_content"
android:layout_below="@+id/textLegend"
android:layout_gravity="center"
android:layout_marginBottom="15dp"
android:background="@drawable/editpicto_edittext_style"
android:ems="10"
android:gravity="center"
......@@ -292,4 +328,13 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/navList"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="right|end"
android:background="#ffeeeeee"/>
</android.support.v4.widget.DrawerLayout>
......@@ -47,4 +47,6 @@
<string name="crop_TextRequired">Por favor, introduzca una leyenda para el pictograma</string>
<string name="uploadingImage">Subiendo imagen al servidor</string>
<string name="cancel">Cancel</string>
<string name="drawer_open">Open Menu</string>
<string name="drawer_close">Close Menu</string>
</resources>
......@@ -7,7 +7,7 @@
TIMESTAMP=`date +"%Y%m%d"`
tar zcf /home/ubuntu/backup/${TIMESTAMP}-sails_src.tgz /home/ubuntu/pictogram/sails/src
mysqldump -u root -p'r00...Tt' pictodb |gzip > /ho:::me/ubuntu/backup/${TIMESTAMP}-mysql.sql.gz
mysqldump -u root -p'r00...Tt' pictodb |gzip > /home/ubuntu/backup/${TIMESTAMP}-mysql.sql.gz
git pull
sudo forever stopall
(cd src; sudo forever start app.js)
......@@ -4,7 +4,7 @@ Changes to be performed manually in servers to upgrade
## AngularJS
(already done in dev)
(already done in dev & pre)
- angular-re-captcha has been replaced by angular-recaptcha, so bower has to be run
- reinstall ui-bootstrap
......@@ -13,14 +13,13 @@ Changes to be performed manually in servers to upgrade
## Database
(ToDo in dev)
- add arasaac to source table
`INSERT INTO `source` (`id`, `name`, `description`) VALUES (3, 'Arasaac', 'Arasaac pictograms collection');`
(already done in dev & pre)
- add arasaac to source table
`INSERT INTO `source` (`id`, `name`, `description`) VALUES (3, 'Arasaac', 'Arasaac pictograms collection');`
- alter table supervisor add arasaac license:
`ALTER TABLE supervisor ADD COLUMN arasaac_license BOOLEAN DEFAULT FALSE;`
(already done in dev)
- load arasaac.sql into MySQL
- load pictocat_tree_populate.sql
`source /vagrant/roles/database/files/pictocat_tree_populate.sql;`
......
......@@ -95,24 +95,42 @@ module.exports = {
* @param {request} req {} (with studentId specified as url parameters)
* @param {response} res
* {
* id: 12,
* office: 1234,
* username: 'johnydoe',
* name: 'Johny',
* surname: 'Doe',
* birthdate: '2009-12-10T00:00:00.000Z',
* gender: 'F',
* country: 'ES',
* pic: 'avatar/nice/url.jpg',
* notes: null,
* lang: 'en-en',
* iat: 123512,
* exp: 1231292,
* attributes: { @see Student.getValidAttributes() },
* current_method: 'Do Things', // May be null
* current_instruction: 'Do Stuff', // May be null
* supervision: 0|1|2, // supervision level according to requester 0 -> office admin, 1 -> tutor, 2 -> therapist
* }
"office": 383,
"id": 92,
"username": "jose",
"name": "AAjose",
"surname": "AAjose antonio",
"birthdate": "2009-05-12T00:00:00.000Z",
"gender": "M",
"country": "ES",
"pic": "/upload/studentAvatar/defaultAvatar.jpg",
"notes": "",
"lang": "es-es",
"current_method": "Comunicación Aumentativa y Adaptativa", // May be "no method"
"current_instruction": "Fase 4 - Estructura de la oración", // May be "no instruction"
"supervision": 2 // supervision level according to requester 0 -> office admin, 1 -> tutor, 2 -> therapist, 3 -> student himself
"attributes": { @see Student.getValidAttributes()
"categories": true,
"input_feedback": {
"vibration": true,
"read": false,
"beep": false,
"highlight": false
},
"input_selection": {
"click": true,
"double_click": false,
"long_press": false,
"drag": true
},
"legend": false,
"legend_size": "normal",
"size": "large",
"picto_background": "#0000ff",
"tape_background": "#00ffff",
"delivery": 0
}
}
*/
getInfo: function (req, res) {
Student.findOne({id: req.params.id_stu})
......@@ -966,7 +984,9 @@ module.exports = {
* legend: true/[false],
* legend_size: '[small]/large',
* expression: 'custom expression',
* color: any valid HEX color or [null]
* color: any valid HEX color or [null],
* sound_uri: path to sound file,
* user_avatar: email (supervisor) or username (student) for associated account
* }
* },
* }
......
......@@ -90,6 +90,8 @@ module.exports = {
color: null,
expression: null,
legend: 'none',
uri_sound: null,
user_avatar: null
};
if (typeof attributes === 'object') {
......@@ -135,6 +137,12 @@ module.exports = {
if (!((/^#([0-9a-f]{3}){1,2}$/i).test(validAttributes.color))) {
delete validAttributes.color;
}
if (typeof validAttributes.sound_uri!== 'string') {
delete validAttributes.sound_uri;
}
if (typeof validAttributes.user_avatar !== 'string') {
delete validAttributes.user_avatar;
}
}
sails.log.verbose('Valid attributes for StuPicto', validAttributes);
return Object.assign({}, defaultAttributes, validAttributes);
......
......@@ -30,6 +30,10 @@
"apply":"Apply",
"annual": "Annual",
"April": "April",
"arasaac_license": "Los símbolos pictográficos utilizados en esta sección son propiedad de CATEDU (http://arasaac.org/) bajo licencia Creative Commons y han sido creados por Sergio Palao.",
"arasaac_license_import": "The pictographic symbols used in this section are the property of CATEDU (http://arasaac.org/) under a Creative Commons license and have been created by Sergio Palau. By importing you accept the ",
"arasaac_license_import2": "terms of use",
"arasaac_license_link": "http://www.arasaac.org/condiciones_uso.php",
"attributes_not_updated": "Changes not saved",
"attributes_updated": "Changes saved",
"attributes_updating": "Saving...",
......@@ -95,6 +99,7 @@
"disclaimer_accept": "I have read and accept <a href='/app/#/disclaimer' target='_blank'>conditions of use</a>",
"disclaimer_p1": "In conformance with Organic Law 15/1999 on Data Protection, Yottacode S.L. informs that it commits to maintaining the secrecy and confidentiality of the personal information received by adopting all the necessary measures to avoid its loss, modification without consent, or unauthorized access in accordance with the Law on Personal Data Protection and its Development Regulation approved by Royal Decree 1720/2007 of December 21. Likewise, the User may exercise, at any given moment, the rights established in Organic Law 15/1999 of December 13 on Personal Data Protection to access, rectify, cancel or oppose the data by notifying Yottacode S.L.",
"disclaimer_p2": "Yottacode S.L. is not responsible for the consequences derived of the use of its products. Yottacode S.L. forbids malicious usage of the Pictogram platform and any access form out from its security policies. Any of these acts may result in legal prosecution.",
"disclaimer_p3": "By using our Services, you are agreeing to allow Yottacode S.L. to use all the data you submit and kept in our servers for analytical and scientific purposes, yet maintaining the privacy of your data.",
"disclaimer_requested": "Conditions of use must be read and accepted",
"double_click": "Double click",
"down": "Down",
......@@ -146,6 +151,7 @@
"highlighted": "Highlighted",
"hours": "hours",
"how_many": "How many?",
"import": "Import",
"inactive_account": "This account has not been activated. Please, follow the link sent to your email address.",
"input_selection": "How to place a pictogram",
"instruction": "Instruction",
......
......@@ -30,6 +30,10 @@
"apply":"Aplicar",
"annual": "Anual",
"April": "Abril",
"arasaac_license": "Los símbolos pictográficos utilizados en esta sección son propiedad de CATEDU (http://arasaac.org/) bajo licencia Creative Commons y han sido creados por Sergio Palao.",
"arasaac_license_import": "Los símbolos pictográficos utilizados en esta sección son propiedad de CATEDU (http://arasaac.org/) bajo licencia Creative Commons y han sido creados por Sergio Palao. Al importarlos acepta las ",
"arasaac_license_import2": "condiciones de uso",
"arasaac_license_link": "http://www.arasaac.org/condiciones_uso.php",
"attributes_not_updated": "Cambios no guardados",
"attributes_updated": "Cambios guardados",
"attributes_updating": "Guardando...",
......@@ -95,6 +99,7 @@
"disclaimer_accept": "He leído y acepto las <a href='/app/#/disclaimer' target='_blank'>condiciones de uso</a>",
"disclaimer_p1": "De conformidad con lo establecido en el Art. 5 de la Ley Orgánica 15/1999 de diciembre de Protección de Datos de Carácter Personal, por el que se regula el derecho de información en la recogida de datos le informamos que los datos de carácter personal que se recogen en este formulario online serán objeto de tratamiento en los ficheros responsabilidad de Yottacode S.L. La finalidad del tratamiento es la de gestionar de forma adecuada la prestación del servicio que nos ha requerido y con fines estadísticos e investigación, y estos datos no serán cedidos a terceros. Asimismo, le informamos de la posibilidad de ejercitar los correspondiente derechos de acceso, rectificación, cancelación y oposición de conformidad con lo establecido en la Ley 15/1999 mediante un escrito a Yottacode S.L. Calle Virgen de la Cabeza 2, 23008, Jaén, incluyendo la fotocopia del DNI del solicitante.",
"disclaimer_p2": "Yottacode S.L. no se hace responsable del uso indebido que de sus productos puedan hacerse, así como de los daños o perjuicidos que pudieran derivarse de los mismos. Los usuarios de la plataforma Pictogram pueden hacer uso libremente de sus funcionalidades, siempre dentro de los límites de acceso establecidos. Un uso inadecuado o que persiga fines maliciosos como el acceso a funciones no autorizadas o la aplicación de técnicas que persigan la ruptura de la seguridad de nuestros sistemas será perseguido legalmente.",
"disclaimer_p3": "Al usar nuestros servicios, acepta permitir a Yottacode S.L. el uso de sus datos con fines estadísticos y científicos, asegurando no obstante la privacidad de sus datos en todo momento.",
"disclaimer_requested": "Las condiciones de uso deben ser leídas y aceptadas",
"double_click": "Doble clic",
"down": "Abajo",
......@@ -146,6 +151,7 @@
"highlighted": "Resaltado",
"hours": "horas",
"how_many": "¿Cuántas?",
"import": "Importar",
"inactive_account": "Esta cuenta no ha sido activada. Por favor, siga el enlace de confirmación enviado a su dirección de correo electrónico.",
"input_selection": "Cómo colocar un pictograma",
"instruction": "Instrucción",
......
......@@ -15,6 +15,7 @@
<h2 translate>disclaimer</h2>
<p translate>disclaimer_p1</p>
<p translate>disclaimer_p2</p>
<p translate>disclaimer_p3</p>
</div>
</div>
......
......@@ -22,7 +22,7 @@
<span class="glyphicon glyphicon-th"></span> SymbolStix
</button>
<button class="btn btn-default" btn-radio="'arasaac'" ng-model="source" ng-click="load_arasaac_pictos()">
<i class="fa fa-th" aria-hidden="true"></i> Arasaac
<i class="fa fa-th" aria-hidden="true"></i> ARASAAC
</button>
<button class="btn btn-default" btn-radio="'ownpictos'" ng-model="source" ng-click="load_own_pictos()">
<span class="glyphicon glyphicon-picture"></span> {{ 'own_pictos' | translate }}
......@@ -76,11 +76,15 @@
<!-- Collections row -->
<div class="row">
<div id="arasaac_agreement" class="col-md-12" ng-show="showArasaacLicense && source == 'arasaac'">
<h2><small>
Los símbolos pictográficos utilizados en esta sección son propiedad de <b>CATEDU</b> (<a href="http://arasaac.org/">Arasaac</a>) bajo licencia Creative Commons y han sido creados por Sergio Palao.
<br>Para usarlos deberá aceptar la licencia de uso haciendo clic sobre el botón importar.</small>
</h2>
<button class="btn btn-primary" ng-click="accept_arasaac()">Importar</button>
<div class="panel panel-warning">
<div class="panel-heading">
<h3 class="panel-title">ARASAAC</h3>
</div>
<div class="panel-body">
<p>{{'arasaac_license_import' | translate}} <a href="{{ 'arasaac_license_link' | translate }}">{{ 'arasaac_license_import2' | translate }}</a>.</p>
<button class="btn btn-primary" ng-click="accept_arasaac()">{{'import' | translate}}</button>
</div>
</div>
</div>
<!-- Collections -->
......@@ -115,8 +119,8 @@
</div><!-- /modal-body -->
<div class="modal-footer">
<div id="arasaac_license" ng-show="source == 'arasaac'">
<p class="small">Los símbolos pictográficos utilizados son propiedad de CATEDU (<a href="http://arasaac.org/">Arasaac</a>) bajo licencia Creative Commons y han sido creados por Sergio Palao</p>
<div class="arasaac_license" ng-show="source == 'arasaac'">
<p><small>{{'arasaac_license' | translate}}</small></p>
</div>
<button class="btn btn-success pull-left" ng-show="source == 'ownpictos'" ngf-select ng-model="picFile" accept="image/*" ngf-change="addOwnPicto()">
<i class="fa fa-folder-open" aria-hidden="true"></i> {{ 'new_img' | translate }}
......
......@@ -12,6 +12,15 @@ dashboardControllers.controller('TranslateController', function(
ngToast,
vcRecaptchaService
) {
// onload, set lang accordingly to stored user settings
if ($window.sessionStorage.user) {
//Session variables update
var obj = JSON.parse($window.sessionStorage.user);
$translate.use(obj.lang);
}
// Changes the language when user click on footer lang
$scope.changeLanguage = function (langKey) {
//Translate update
......@@ -41,7 +50,11 @@ dashboardControllers.controller('TranslateController', function(
}
// Reload captcha according to language (only once instance per page, so id is always 0)
vcRecaptchaService.useLang(0, langKey.substr(0,2)); //TODO: REVISAR reCaptcha Widget ID not exists
try {
vcRecaptchaService.useLang(0, langKey.substr(0,2));
} catch (err) {}
// Reload page
$window.location.reload();
};
});
......@@ -1023,6 +1023,10 @@ form .progress {
.method-opt{
font-weight: 600;
}
.arasaac_license{
text-align: left;
color: #6c6c6c;
}
.header-image {
width: 100%;
......
......@@ -8,6 +8,12 @@ module.exports = function (grunt) {
src: ['modules/**/*.html'],
dest: 'assets/app/',
filter: 'isFile'
},
{
cwd: 'assets/app/bower_components/bootstrap/dist/css/',
src: 'bootstrap.css.map',
dest: 'assets/app/css',
expand: true
}
]
},
......
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