Commit e6607142 by Jose Antonio

Merged branch develop into develop

parents 2ac2ba61 08390921
...@@ -178,14 +178,32 @@ public class Device extends SQLiteOpenHelper { ...@@ -178,14 +178,32 @@ public class Device extends SQLiteOpenHelper {
return user; return user;
} }
/**
* Para saber si un supervisor esta en la bbdd local
* @param id_sup
* @return
* @throws JSONException
*/
public Boolean isSupervisorOnLocal(int id_sup) throws JSONException{
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(" SELECT * FROM supervisor WHERE id = " + id_sup, null);
if(cursor.moveToFirst())
return true;
cursor.close();
return false;
}
//TODO: Recuperar los users (supervisors + students) de un alumno
public Vector<User> recoverSupervisors(Integer id_stu) throws JSONException{ public Vector<User> recoverSupervisors(Integer id_stu) throws JSONException{
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Vector<User> users = new Vector<>(); Vector<User> users = new Vector<>();
Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null); Cursor cursor = db.rawQuery(" SELECT * FROM supervisor,student WHERE "+id_stu+ " = (SELECT id_stu from users WHERE id_stu = " +id_stu+")" ,null);
while (cursor.moveToNext()) while (cursor.moveToNext())
if (cursor.getInt(0) == id_stu) Log.i("TAG_PRUEBAS","Fila: "+cursor.getInt(0)+cursor.getString(1)+ cursor.getString(2)+ cursor.getString(3)+ cursor.getString(4)+ cursor.getString(5)+ cursor.getString(6)+ cursor.getString(7)+ cursor.getString(8)+
cursor.getInt(9)+ cursor.getString(10)+ cursor.getString(11)+ cursor.getString(12)+ cursor.getString(13)+ cursor.getString(14)+ cursor.getString(15)+ cursor.getString(16)+ cursor.getString(17)+ cursor.getString(18));
/*if (cursor.getInt(9) == id_stu)
users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8),
cursor.getInt(9), cursor.getString(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(18))); cursor.getInt(9), cursor.getString(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(18)));*/
cursor.close(); cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return users; return users;
...@@ -268,6 +286,48 @@ public class Device extends SQLiteOpenHelper { ...@@ -268,6 +286,48 @@ public class Device extends SQLiteOpenHelper {
return users; return users;
} }
/**
* To insert a tuple on users
* @param id_stu
* @param id_sup
*/
public void insertUserOnUsers(int id_stu, int id_sup){
SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction();
db.execSQL("INSERT INTO users values (" +
id_stu + ", " +
id_sup +
")");
db.setTransactionSuccessful();
db.endTransaction();
}
/**
* For insert a new supervisor on the local database
*
*/
public void insertSupervisor(int id, String email,String pwd,String name,String surname,String url_image,String gender,String lang,String tts_engine,String office) {
SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction();
db.execSQL("INSERT INTO supervisor values (" +
id+ ", " +
"'" + email + "', " +
(pwd==null || pwd.length()==0 ? "NULL" : "'"+pwd+"'") + ", "+
"'" + name + "', " +
"'" + surname + "', " +
"'" + url_image + "', " +
"'" + gender + "', " +
"'" + lang + "', " +
"'" + tts_engine + "', " +
"'" + office + "')");
db.setTransactionSuccessful();
db.endTransaction();
Log.i("TAG_PRUEBAS","Supervisor: "+email+" insertado");
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
}
public void insertUser(User user) { public void insertUser(User user) {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction(); db.beginTransaction();
...@@ -297,10 +357,14 @@ public class Device extends SQLiteOpenHelper { ...@@ -297,10 +357,14 @@ public class Device extends SQLiteOpenHelper {
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
} }
public void deleteUser(User user) { /**
* Delete all the pairs <id_sup,id_stu> of a student
* @param stu_id
*/
public void deleteSupervisorOfStudentUser(int stu_id) {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction(); db.beginTransaction();
db.execSQL("DELETE FROM users_detail WHERE id_sup = " + user.get_id_sup()); db.execSQL("DELETE FROM users WHERE id_stu = "+stu_id);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
db.endTransaction(); db.endTransaction();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
......
...@@ -9,7 +9,6 @@ import com.koushikdutta.ion.Response; ...@@ -9,7 +9,6 @@ import com.koushikdutta.ion.Response;
import com.yottacode.net.RestapiWrapper; import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.R; import com.yottacode.pictogram.R;
import com.yottacode.pictogram.action.VocabularyAction; import com.yottacode.pictogram.action.VocabularyAction;
import com.yottacode.pictogram.dao.Device;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
...@@ -24,7 +23,6 @@ import java.io.IOException; ...@@ -24,7 +23,6 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
/** /**
...@@ -318,7 +316,7 @@ public class PictoUploader { ...@@ -318,7 +316,7 @@ public class PictoUploader {
uploadTranslation(picto.get_id(), listener); uploadTranslation(picto.get_id(), listener);
} }
}else{ }else{
GUITools.show_alert(PCBcontext.getActivityContext(), Integer.parseInt(R.string.upload_error+"Imagen"), PictoUploader.this.picto.get_translation()); GUITools.show_alert(PCBcontext.getActivityContext(), R.string.upload_error, PictoUploader.this.picto.get_translation());
} }
} }
......
...@@ -90,14 +90,18 @@ public final class PCBcontext { ...@@ -90,14 +90,18 @@ public final class PCBcontext {
} }
public static void unset_user() { public static void unset_user() {
Log.i(PCBcontext.class.getCanonicalName(), "User unset. Student " + getPcbdb().getCurrentUser().get_name_stu()); Log.e(PCBcontext.class.getCanonicalName(), "User unset. Student " + getPcbdb().getCurrentUser().get_name_stu());
if (room!=null) room.exit(); if (room!=null) room.exit();
pcbdb = null; pcbdb = null;
room = null; room = null;
vocabulary = null; vocabulary = null;
getNetService().notifyStatus(); getNetService().notifyStatus();
} }
@Override
protected void finalize() {
Log.e("PCBcontext", "FINALIZE Pictogram Activity");
}
/** /**
* *
* @return true if a given user has been logged into the system (the login window was successfully filled) * @return true if a given user has been logged into the system (the login window was successfully filled)
......
package com.yottacode.tools; package com.yottacode.tools;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter; import android.graphics.BlurMaskFilter;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
...@@ -8,12 +9,22 @@ import android.graphics.Matrix; ...@@ -8,12 +9,22 @@ import android.graphics.Matrix;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.os.Environment;
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
/** /**
* Created by Fernando on 15/03/2016. * Created by Fernando on 15/03/2016.
*/ */
public class BitmapTools { public class BitmapTools {
Bitmap bitmap; private static String LOG_TAG=BitmapTools.class.getName();
Bitmap bitmap;
public BitmapTools(Bitmap bitmap) { this.bitmap=bitmap;} public BitmapTools(Bitmap bitmap) { this.bitmap=bitmap;}
public Bitmap get() {return this.bitmap;} public Bitmap get() {return this.bitmap;}
...@@ -167,4 +178,36 @@ public class BitmapTools { ...@@ -167,4 +178,36 @@ public class BitmapTools {
canvas.drawBitmap(new BitmapTools(drawable.getBitmap()).resize(w,h).get(), canvas.drawBitmap(new BitmapTools(drawable.getBitmap()).resize(w,h).get(),
(int)((this.bitmap.getWidth()-w)/2),(int)((this.bitmap.getHeight()-h)/2),null); (int)((this.bitmap.getWidth()-w)/2),(int)((this.bitmap.getHeight()-h)/2),null);
} }
public static void save_temporal(Bitmap bitmap) {
File f3=new File(Environment.getExternalStorageDirectory()+"/inpaint/");
if(!f3.exists())
f3.mkdirs();
OutputStream outStream = null;
File file = new File(Environment.getExternalStorageDirectory() + "/inpaint/"+"seconds"+".png");
try {
outStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static Bitmap load_temporal() {
InputStream inStream;
inStream = null;
File file = new File(Environment.getExternalStorageDirectory() + "/inpaint/"+"seconds"+".png");
try {
inStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.e(BitmapTools.LOG_TAG,e.getMessage());
}
Bitmap originalBitmap = BitmapFactory.decodeStream(inStream);
file.delete();
return originalBitmap ;
}
} }
...@@ -62,4 +62,7 @@ ...@@ -62,4 +62,7 @@
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="landscape" /> android:screenOrientation="landscape" />
</application> </application>
</manifest> </manifest>
...@@ -2,8 +2,6 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator; ...@@ -2,8 +2,6 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Point;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
...@@ -11,14 +9,10 @@ import android.widget.RelativeLayout; ...@@ -11,14 +9,10 @@ import android.widget.RelativeLayout;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity;
import com.yottacode.pictogram.tabletlibrary.gui.login.MainActivity;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools; import com.yottacode.tools.BitmapTools;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import static android.graphics.Color.argb; import static android.graphics.Color.argb;
...@@ -122,10 +116,11 @@ public class PictoMenu { ...@@ -122,10 +116,11 @@ public class PictoMenu {
intent.putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col); intent.putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col);
} }
ByteArrayOutputStream stream = new ByteArrayOutputStream(); /*ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
intent.putExtra(IMAGE_PICTO, byteArray); intent.putExtra(IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(bitmap);
intent.putExtra(IS_EDIT,true); intent.putExtra(IS_EDIT,true);
activity.startActivityForResult(intent,EditPictoActivity.EDIT_PICTO_REQUEST); activity.startActivityForResult(intent,EditPictoActivity.EDIT_PICTO_REQUEST);
......
...@@ -56,12 +56,12 @@ import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet; ...@@ -56,12 +56,12 @@ import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.tts.TTSHelper; import com.yottacode.pictogram.tts.TTSHelper;
import com.yottacode.tools.BitmapTools;
import com.yottacode.tools.GUITools; import com.yottacode.tools.GUITools;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
...@@ -393,6 +393,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -393,6 +393,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
@Override @Override
protected void onPause() { protected void onPause() {
Log.e(this.LOG_TAG,"ONPAUSE");
super.onPause(); super.onPause();
this.pictoCategoryGridAdapter.allPictosInGrid(); this.pictoCategoryGridAdapter.allPictosInGrid();
this.pictoMainGridAdapter.allPictosInGrid(); this.pictoMainGridAdapter.allPictosInGrid();
...@@ -408,6 +409,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -408,6 +409,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
@Override @Override
protected void onDestroy() { protected void onDestroy() {
Log.e(LOG_TAG, "destroy Pictogram Activity");
super.onDestroy(); super.onDestroy();
if (tts != null) { if (tts != null) {
tts.destroy(); tts.destroy();
...@@ -1215,11 +1217,11 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1215,11 +1217,11 @@ protected void showOnlyTape(boolean onlyTape) {
Intent intent = new Intent(this, EditPictoActivity.class); Intent intent = new Intent(this, EditPictoActivity.class);
ByteArrayOutputStream stream = new ByteArrayOutputStream(); /* ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.PNG, 100, stream); image.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray); intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(image);
startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST); startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST);
} }
......
...@@ -6,7 +6,6 @@ import android.content.Intent; ...@@ -6,7 +6,6 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point; import android.graphics.Point;
import android.media.MediaActionSound; import android.media.MediaActionSound;
import android.media.MediaPlayer; import android.media.MediaPlayer;
...@@ -33,7 +32,6 @@ import android.widget.Button; ...@@ -33,7 +32,6 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
...@@ -41,27 +39,25 @@ import android.widget.Toast; ...@@ -41,27 +39,25 @@ import android.widget.Toast;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.dao.User; import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.grammar.Vocabulary;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular; import com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictoMenu; import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictoMenu;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.BitmapTools;
import com.yottacode.tools.GUITools; import com.yottacode.tools.GUITools;
import org.json.JSONException; import org.json.JSONException;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Vector; import java.util.Vector;
import pl.droidsonroids.gif.GifTextView; import pl.droidsonroids.gif.GifTextView;
import static java.lang.Thread.sleep; import static java.lang.Thread.sleep;
/** /**
...@@ -70,6 +66,7 @@ import static java.lang.Thread.sleep; ...@@ -70,6 +66,7 @@ import static java.lang.Thread.sleep;
public class EditPictoActivity extends Activity { public class EditPictoActivity extends Activity {
private static final CharSequence NO_SUP_TEXT = "____________";
Picto p; Picto p;
private boolean editar; private boolean editar;
Random nRandom = new Random(); Random nRandom = new Random();
...@@ -101,8 +98,8 @@ public class EditPictoActivity extends Activity { ...@@ -101,8 +98,8 @@ public class EditPictoActivity extends Activity {
EditText legend; EditText legend;
//For Associated Supervisors///////////////////////////////////////////////////////// //For Associated Supervisors/////////////////////////////////////////////////////////
Button desplegableSupervisores; Button supAsociado;
TextView supAsociado;
private ListView mDrawerList; private ListView mDrawerList;
private ArrayAdapter<String> mAdapter; private ArrayAdapter<String> mAdapter;
...@@ -253,7 +250,7 @@ public class EditPictoActivity extends Activity { ...@@ -253,7 +250,7 @@ public class EditPictoActivity extends Activity {
supervisoresAdapter.add(supervisor.get_name_sup()+", "+supervisor.get_surname_sup()+ "\n" +supervisor.get_email_sup() ); supervisoresAdapter.add(supervisor.get_name_sup()+", "+supervisor.get_surname_sup()+ "\n" +supervisor.get_email_sup() );
} }
} }
supervisoresAdapter.add(NO_SUP_TEXT+"\n"+NO_SUP_TEXT);
//String supervisors = PCBcontext.getPcbdb().getCurrentUser().get_Supervisors(); //String supervisors = PCBcontext.getPcbdb().getCurrentUser().get_Supervisors();
//Log.i(DEBUG_MESSAGE,"Supervisores: "+ supervisors); //Log.i(DEBUG_MESSAGE,"Supervisores: "+ supervisors);
//ArrayList<String> supervisores = new ArrayList<>(); //ArrayList<String> supervisores = new ArrayList<>();
...@@ -328,8 +325,7 @@ public class EditPictoActivity extends Activity { ...@@ -328,8 +325,7 @@ public class EditPictoActivity extends Activity {
okButton = (Button) findViewById(R.id.okButton); okButton = (Button) findViewById(R.id.okButton);
cancelButton = (Button) findViewById(R.id.cancelButton); cancelButton = (Button) findViewById(R.id.cancelButton);
desplegableSupervisores = (Button) findViewById(R.id.botonDesplegable); supAsociado = (Button) findViewById(R.id.botonSupAsociado);//(TextView) findViewById(R.id.sup_actual);
supAsociado = (TextView) findViewById(R.id.sup_actual);
botonGrabar = (BotonCircular) findViewById(R.id.botonGrabar); botonGrabar = (BotonCircular) findViewById(R.id.botonGrabar);
botonReproducir = (BotonCircular) findViewById(R.id.reproducir); botonReproducir = (BotonCircular) findViewById(R.id.reproducir);
...@@ -366,16 +362,16 @@ public class EditPictoActivity extends Activity { ...@@ -366,16 +362,16 @@ public class EditPictoActivity extends Activity {
if(editar){ if(editar){
p = PCBcontext.getVocabulary().get_picto(getIntent().getExtras().getInt(Picto.JSON_ATTTRS.CATEGORY),getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE)); p = PCBcontext.getVocabulary().get_picto(getIntent().getExtras().getInt(Picto.JSON_ATTTRS.CATEGORY),getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE));
legend.setText(p.get_translation()); legend.setText(p.get_translation());
supAsociado.setText(p.get_user_avatar()); supAsociado.setText(p.get_user_avatar()==null ? NO_SUP_TEXT : p.get_user_avatar());
} }
legend.setHorizontallyScrolling(false); legend.setHorizontallyScrolling(false);
legend.setMaxLines(1); legend.setMaxLines(1);
legend.setSingleLine(true); legend.setSingleLine(true);
//Obtener imagen del intent //Obtener imagen del intent
byte[] byteArray = getIntent().getByteArrayExtra(PictoMenu.IMAGE_PICTO); /*byte[] byteArray = getIntent().getByteArrayExtra(PictoMenu.IMAGE_PICTO);*/
final Bitmap imagePicto = scale_image(BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length));
final Bitmap imagePicto = scale_image(BitmapTools.load_temporal());
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.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.setImageBitmap(imagePicto);
cropImageView.setMaxWidth(imagePicto.getWidth()); cropImageView.setMaxWidth(imagePicto.getWidth());
...@@ -393,7 +389,7 @@ public class EditPictoActivity extends Activity { ...@@ -393,7 +389,7 @@ public class EditPictoActivity extends Activity {
//} //}
pathNumber = nRandom.nextInt(); pathNumber = nRandom.nextInt();
desplegableSupervisores.setOnClickListener(new View.OnClickListener() { supAsociado.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT))
...@@ -428,7 +424,7 @@ public class EditPictoActivity extends Activity { ...@@ -428,7 +424,7 @@ public class EditPictoActivity extends Activity {
String filepath = null; String filepath = null;
String audioPath = null; String audioPath = null;
try { try {
id_pic = getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE); id_pic = getIntent().getExtras()!=null ? getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE) : 0;
filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_pic + ".png" filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_pic + ".png"
...@@ -478,7 +474,7 @@ public class EditPictoActivity extends Activity { ...@@ -478,7 +474,7 @@ public class EditPictoActivity extends Activity {
intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,audioPath); //Mandar el path del audio 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.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.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText()); intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText().equals(NO_SUP_TEXT)?null:supAsociado.getText());
//p.setUriSound(audioPath); //p.setUriSound(audioPath);
...@@ -706,10 +702,11 @@ public class EditPictoActivity extends Activity { ...@@ -706,10 +702,11 @@ public class EditPictoActivity extends Activity {
Bitmap rescaled = scale_image(imagen); Bitmap rescaled = scale_image(imagen);
cropImageView.setImageBitmap(rescaled); cropImageView.setImageBitmap(rescaled);
ByteArrayOutputStream stream = new ByteArrayOutputStream(); /*ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream); rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray); getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(rescaled);
} }
break; break;
...@@ -726,10 +723,11 @@ public class EditPictoActivity extends Activity { ...@@ -726,10 +723,11 @@ public class EditPictoActivity extends Activity {
Bitmap rescaled = scale_image(bitmap); Bitmap rescaled = scale_image(bitmap);
cropImageView.setImageBitmap(rescaled); cropImageView.setImageBitmap(rescaled);
ByteArrayOutputStream stream = new ByteArrayOutputStream(); /* ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream); rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray); getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(rescaled);
} }
break; break;
} }
......
...@@ -226,38 +226,41 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -226,38 +226,41 @@ public class StudentFragmentGrid extends Fragment{
@Override @Override
public void result(JSONArray supervisors) { public void result(JSONArray supervisors) {
Vector<Integer> idSupervisoresJSON = new Vector<Integer>(); //TODO: Obtener supervisores del JSON
//Vector<Integer> idSupervisoresJSON = new Vector<Integer>();
for (int i=0;i<supervisors.length();i++) { for (int i=0;i<supervisors.length();i++) {
JSONObject supervisor = null; JSONObject supervisor = null;
try { try {
supervisor = supervisors.getJSONObject(i); supervisor = supervisors.getJSONObject(i);
idSupervisoresJSON.add((Integer) supervisor.get("id")); //idSupervisoresJSON.add((Integer) supervisor.get("id"));
//User user = ;
User user = PCBcontext.getDevice().findUser(stu_id,(int) supervisor.get("id")); //Para comprobar si ya existe en local if(!PCBcontext.getDevice().isSupervisorOnLocal((int) supervisor.get("id"))) {//Para comprobar si ya existe en local
PCBcontext.getDevice().insertSupervisor(supervisor.getInt("id"),supervisor.getString("email"),supervisor.getString("name"),null,supervisor.getString("surname"),
if(user==null) { supervisor.getString("pic"),supervisor.getString("gender"),supervisor.getString("lang"),supervisor.getString("ttsEngine"),supervisor.getString("office"));
PCBcontext.getDevice().insertUser(new User(stu_id, PCBcontext.getPcbdb().getCurrentUser().get_nickname_stu(), PCBcontext.getPcbdb().getCurrentUser().get_pwd_stu() /*PCBcontext.getDevice().insertUser(new User(stu_id, PCBcontext.getPcbdb().getCurrentUser().get_nickname_stu(), PCBcontext.getPcbdb().getCurrentUser().get_pwd_stu()
, PCBcontext.getPcbdb().getCurrentUser().get_name_stu(), PCBcontext.getPcbdb().getCurrentUser().get_surname_stu(), PCBcontext.getPcbdb().getCurrentUser().get_url_img_stu() , PCBcontext.getPcbdb().getCurrentUser().get_name_stu(), PCBcontext.getPcbdb().getCurrentUser().get_surname_stu(), PCBcontext.getPcbdb().getCurrentUser().get_url_img_stu()
, PCBcontext.getPcbdb().getCurrentUser().get_gender_stu(), PCBcontext.getPcbdb().getCurrentUser().get_lang_stu(), PCBcontext.getPcbdb().getCurrentUser().get_json_attrs(), , PCBcontext.getPcbdb().getCurrentUser().get_gender_stu(), PCBcontext.getPcbdb().getCurrentUser().get_lang_stu(), PCBcontext.getPcbdb().getCurrentUser().get_json_attrs(),
(int) supervisor.get("id"), supervisor.get("email").toString(), null, supervisor.get("name").toString(), supervisor.get("surname").toString(), supervisor.get("pic").toString(), (int) supervisor.get("id"), supervisor.get("email").toString(), null, supervisor.get("name").toString(), supervisor.get("surname").toString(), supervisor.get("pic").toString(),
supervisor.get("gender").toString(), supervisor.get("lang").toString(), supervisor.get("ttsEngine").toString(), supervisor.get("office").toString())); supervisor.get("gender").toString(), supervisor.get("lang").toString(), supervisor.get("ttsEngine").toString(), supervisor.get("office").toString()));*/
}else{
Log.i("TAG_PRUEBAS","Usuario con id: "+supervisor.getString("email")+" ya existe");
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
try { /*try {
Vector<User> supervisorsLocal = PCBcontext.getDevice().recoverSupervisors(stu_id); Vector<User> supervisorsLocal = PCBcontext.getDevice().recoverSupervisors(stu_id);
for(User user: supervisorsLocal){ for(User user: supervisorsLocal){
if(!idSupervisoresJSON.contains(user.get_id_sup())){ if(!idSupervisoresJSON.contains(user.get_id_sup())){
PCBcontext.getDevice().deleteUser(user); PCBcontext.getDevice().deleteUser(stu_id);
} }
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }*/
//PCBcontext.getPcbdb().getCurrentUser().set_Supervisors(supervisorsFormat); //PCBcontext.getPcbdb().getCurrentUser().set_Supervisors(supervisorsFormat);
} }
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:textColor="@color/BlancoApp"
android:background="@color/VerdeApp" android:background="@color/VerdeApp"
android:paddingBottom="8dp" android:paddingBottom="8dp"
android:paddingTop="@dimen/content_padding_half" android:paddingTop="@dimen/content_padding_half"
android:text="@string/titleCropperNew" android:text="@string/titleCropperNew"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/BlancoApp"
android:textSize="24sp" /> android:textSize="24sp" />
<LinearLayout <LinearLayout
...@@ -109,34 +109,34 @@ ...@@ -109,34 +109,34 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/textAssociated" android:id="@+id/textView_Supevisor"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_marginTop="15dp"
android:text="Asociar a:" android:text="Supervisor:"
android:textColor="@color/gray" android:textColor="@color/gray"
android:textSize="20sp" /> android:textSize="20sp" />
<Button <Button
android:id="@+id/botonDesplegable" android:id="@+id/botonSupAsociado"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="Ver" /> android:textColor="@color/BlancoApp"
android:background="@color/VerdeApp"
android:text="___________" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:background="@color/VerdeApp"
/>
</LinearLayout> </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 <TextView
android:id="@+id/textLegend" android:id="@+id/textLegend"
...@@ -163,13 +163,21 @@ ...@@ -163,13 +163,21 @@
android:textColorLink="?android:attr/colorAccent" android:textColorLink="?android:attr/colorAccent"
android:textCursorDrawable="@null" android:textCursorDrawable="@null"
android:textSize="20sp" /> android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="@color/VerdeApp"
android:paddingBottom="4dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
/>
<TextView <TextView
android:id="@+id/textView_Audio" android:id="@+id/textView_Audio"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:text="Audio" android:text="Audio:"
android:textColor="@color/gray" android:textColor="@color/gray"
android:textSize="20sp" /> android:textSize="20sp" />
...@@ -291,9 +299,13 @@ ...@@ -291,9 +299,13 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:background="@color/VerdeApp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
...@@ -335,6 +347,8 @@ ...@@ -335,6 +347,8 @@
android:layout_width="250dp" android:layout_width="250dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="right|end" android:layout_gravity="right|end"
android:background="#ffeeeeee"/> android:background="@color/VerdeApp"
android:headerDividersEnabled="false"
android:textColor="@color/BlancoApp" />
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>
...@@ -62,13 +62,6 @@ ...@@ -62,13 +62,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
...@@ -76,6 +69,13 @@ ...@@ -76,6 +69,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
...@@ -121,5 +121,17 @@ ...@@ -121,5 +121,17 @@
<orderEntry type="library" exported="" name="ion-2.1.9" level="project" /> <orderEntry type="library" exported="" name="ion-2.1.9" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" />
<orderEntry type="module" module-name="commonlibrary" exported="" /> <orderEntry type="module" module-name="commonlibrary" exported="" />
<orderEntry type="library" exported="" name="android-android-24" level="project" />
<orderEntry type="library" exported="" name="okhttp-ws-2.3.0" level="project" />
<orderEntry type="library" exported="" name="socket.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.3.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="library" exported="" name="okio-1.3.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
<orderEntry type="library" exported="" name="engine.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="json-20090211" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
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