Commit a3974107 by Arturo Montejo Ráez

Merge branch 'develop' of http://scm.ujaen.es/softuno/pictogram into sessionRefactor

parents 700e75a0 4378e15d
Showing with 599 additions and 367 deletions
...@@ -66,6 +66,9 @@ android/Pictogram/supervisor_tablet/supervisor_tablet.iml ...@@ -66,6 +66,9 @@ android/Pictogram/supervisor_tablet/supervisor_tablet.iml
android/Pictogram/tabletlibrary/tabletlibrary.iml android/Pictogram/tabletlibrary/tabletlibrary.iml
android/Pictogram/yotta_tablet/yotta_tablet.iml android/Pictogram/yotta_tablet/yotta_tablet.iml
android/Pictogram/watch/watch.iml android/Pictogram/watch/watch.iml
android/Pictogram/yotta_tablet.iml
android/Pictogram/tabletlibrary.iml
android/Pictogram/supervisor_tablet.iml
# OS generated files # # OS generated files #
###################### ######################
......
...@@ -10,7 +10,7 @@ android { ...@@ -10,7 +10,7 @@ android {
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
resValue "string", "db_name", "PCB.db" resValue "string", "db_name", "PCB.db"
resValue "integer", "db_version", "2" resValue "integer", "db_version", "3"
resValue "string", "app_version", "0.1" resValue "string", "app_version", "0.1"
resValue "string", "core_vocabulary", "core_vocabulary" resValue "string", "core_vocabulary", "core_vocabulary"
resValue "string", "apk", "to_be_set_in_subproject" resValue "string", "apk", "to_be_set_in_subproject"
......
...@@ -181,7 +181,6 @@ public class Device extends SQLiteOpenHelper { ...@@ -181,7 +181,6 @@ public class Device extends SQLiteOpenHelper {
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.query("users_detail", null, null, null, null, null, null, null);
while (cursor.moveToNext()) while (cursor.moveToNext())
if (cursor.getInt(9) == id_sup) if (cursor.getInt(9) == id_sup)
users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8),
......
...@@ -153,10 +153,10 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -153,10 +153,10 @@ public class PCBDBHelper extends SQLiteOpenHelper {
Cursor cursor = db.query("collection_detail", null, "id_stu=?", new String[]{String.valueOf(id_stu)}, null, null, null, null); Cursor cursor = db.query("collection_detail", null, "id_stu=?", new String[]{String.valueOf(id_stu)}, null, null, null, null);
Log.i(LOG_TAG, "Local recovering " + cursor.getCount() + " pictos for student " + id_stu + " from local DB"); Log.i(LOG_TAG, "Local recovering " + cursor.getCount() + " pictos for student " + id_stu + " from local DB");
cursor.moveToFirst(); cursor.moveToFirst();
while (cursor.moveToNext()) { if (cursor.getCount()>0) do{
Picto picto = new Picto(cursor.getInt(1), cursor.getString(2), cursor.getString(3), cursor.getString(4)); Picto picto = new Picto(cursor.getInt(1), cursor.getString(2), cursor.getString(3), cursor.getString(4));
vocabulary.loadPicto(picto); vocabulary.loadPicto(picto);
} }while (cursor.moveToNext());
cursor.close(); cursor.close();
db.close(); db.close();
......
...@@ -2,6 +2,8 @@ package com.yottacode.pictogram.dao; ...@@ -2,6 +2,8 @@ package com.yottacode.pictogram.dao;
import android.graphics.Color; import android.graphics.Color;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log; import android.util.Log;
import com.yottacode.pictogram.action.VocabularyAction; import com.yottacode.pictogram.action.VocabularyAction;
...@@ -12,6 +14,8 @@ import com.yottacode.pictogram.tools.PCBcontext; ...@@ -12,6 +14,8 @@ import com.yottacode.pictogram.tools.PCBcontext;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.Serializable;
/** /**
* A object which represents a pictogram * A object which represents a pictogram
...@@ -19,9 +23,7 @@ import org.json.JSONObject; ...@@ -19,9 +23,7 @@ import org.json.JSONObject;
* @author Fernando Martinez Santiago * @author Fernando Martinez Santiago
* @version 1.0 * @version 1.0
*/ */
public class public class Picto extends Img {
Picto extends Img {
public final static class JSON_ATTTRS { public final static class JSON_ATTTRS {
public static String CATEGORY = "id_cat"; public static String CATEGORY = "id_cat";
......
...@@ -131,7 +131,7 @@ public class UserLogin { ...@@ -131,7 +131,7 @@ public class UserLogin {
Class PictogramActivity, Class LoginActivity) { Class PictogramActivity, Class LoginActivity) {
try { try {
Vector<User> localUsers = PCBcontext.getDevice().findUser(email, password); Vector<User> localUsers = PCBcontext.getDevice().findUser(email, password);
Log.i(this.getClass().getCanonicalName(), "Offline login request for supervisor "+email); Log.i(this.getClass().getCanonicalName(), "Offline login request for supervisor "+email+localUsers.elementAt(0).get_email_sup()+localUsers.elementAt(0).is_supervisor());
if (localUsers.size() == 1) { if (localUsers.size() == 1) {
PCBcontext.set_user(localUsers.elementAt(0), null, null); PCBcontext.set_user(localUsers.elementAt(0), null, null);
......
...@@ -36,7 +36,8 @@ import java.util.Vector; ...@@ -36,7 +36,8 @@ import java.util.Vector;
public class Vocabulary implements Iterable<Picto> { public class Vocabulary implements Iterable<Picto> {
Hashtable<Integer,LinkedList<Picto>> pictos; private static final String LOG_TAG = Vocabulary.class.getName();
Hashtable<Integer,LinkedList<Picto>> pictos;
static int DEFAULT_VOCABULARY_SIZE=200; static int DEFAULT_VOCABULARY_SIZE=200;
ImgDownloader.iImgDownloaderListener imgListener; ImgDownloader.iImgDownloaderListener imgListener;
private ActionTalk actionTalk; private ActionTalk actionTalk;
...@@ -138,7 +139,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -138,7 +139,7 @@ public class Vocabulary implements Iterable<Picto> {
try { try {
Log.i(this.getClass().getCanonicalName(), "Picto added while offline. Picto translation: '" + Log.i(this.getClass().getCanonicalName(), "Picto added while offline. Picto translation: '" +
picto.get_translation() + "', id:" + picto.get_id() + " Local status?" + picto.local_status()); picto.get_translation() + "', id:" + picto.get_id() + " Local status?" + picto.local_status());
new PictoUploader(picto).upload(PCBcontext.getContext()); new PictoUploader(picto).upload();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
Log.e(this.getClass().getName(), " Picto json error from server: " + picto.toString()); Log.e(this.getClass().getName(), " Picto json error from server: " + picto.toString());
...@@ -335,7 +336,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -335,7 +336,7 @@ public class Vocabulary implements Iterable<Picto> {
* @seealso com.yottacode.pictogram.dao.PCBDBHelper.getStudentVocabulary * @seealso com.yottacode.pictogram.dao.PCBDBHelper.getStudentVocabulary
*/ */
public void loadPicto(Picto picto) { public void loadPicto(Picto picto) {
Log.i(LOG_TAG, "load picto "+picto.get_translation());
LinkedList<Picto> pictos_cat; LinkedList<Picto> pictos_cat;
if (this.pictos.containsKey(picto.get_category())) if (this.pictos.containsKey(picto.get_category()))
pictos_cat = pictos.get(picto.get_category()); pictos_cat = pictos.get(picto.get_category());
......
...@@ -17,7 +17,6 @@ import com.yottacode.pictogram.dao.DeviceHelper; ...@@ -17,7 +17,6 @@ import com.yottacode.pictogram.dao.DeviceHelper;
import com.yottacode.pictogram.dao.LoginException; import com.yottacode.pictogram.dao.LoginException;
import com.yottacode.pictogram.dao.User; import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
...@@ -214,10 +213,9 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -214,10 +213,9 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
} }
}); });
notifyStatus(); notifyStatus();
Log.e(LOG_TAG, "working");
}catch(Exception e) { }catch(Exception e) {
Log.e(LOG_TAG,"NOT WORKING BECAUSE:"+e.getMessage()); Log.e(LOG_TAG,"THREAD NOT WORKING BECAUSE:"+e.getMessage());
this.restart_app(true); this.restart_app(true);
} }
} }
......
package com.yottacode.pictogram.net; package com.yottacode.pictogram.net;
import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.util.Log; import android.util.Log;
...@@ -22,7 +21,6 @@ import org.json.JSONObject; ...@@ -22,7 +21,6 @@ import org.json.JSONObject;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.HttpRetryException;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
...@@ -135,13 +133,13 @@ public class PictoUploader { ...@@ -135,13 +133,13 @@ public class PictoUploader {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
Log.i(this.getClass().getCanonicalName(), " Attributes uploaded: " + result.toString()); Log.i(this.getClass().getCanonicalName(), " Attributes uploaded: " + result.toString());
listener.success(true); listener.success(true,result.toString());
} }
@Override @Override
public void error(RestapiWrapper.HTTPException e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getCanonicalName(), " Error uploading attributes: " + e.getLocalizedMessage()); Log.e(this.getClass().getCanonicalName(), " Error uploading attributes: " + e.getLocalizedMessage());
listener.success(false); listener.success(false,e.getLocalizedMessage());
} }
}); });
...@@ -170,13 +168,13 @@ public class PictoUploader { ...@@ -170,13 +168,13 @@ public class PictoUploader {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
Log.i(this.getClass().getCanonicalName(), "Uploaded translation result: " + result.toString()); Log.i(this.getClass().getCanonicalName(), "Uploaded translation result: " + result.toString());
listener.success(true); listener.success(true,result.toString());
} }
@Override @Override
public void error(RestapiWrapper.HTTPException e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getCanonicalName(), "Error uploading translation: " + e.getLocalizedMessage()+" Picto:"+params.get("picto")+" Lang:"+params.get("lang")+" Text:"+params.get("text")); Log.e(this.getClass().getCanonicalName(), "Error uploading translation: " + e.getLocalizedMessage()+" Picto:"+params.get("picto")+" Lang:"+params.get("lang")+" Text:"+params.get("text"));
listener.success(false); listener.success(false,e.getMessage());
} }
}); });
} }
...@@ -188,23 +186,28 @@ public class PictoUploader { ...@@ -188,23 +186,28 @@ public class PictoUploader {
* iii) to upload the expression * iii) to upload the expression
* *
**/ **/
public void upload(final Context context) throws IOException { public void upload() throws IOException {
final int local_img_id = this.picto.get_id(); final int local_img_id = this.picto.get_id();
final boolean imgUpload_success = uploadImg(this.picto); final boolean imgUpload_success = uploadImg(this.picto);
iPictoUploaderListener listener = new iPictoUploaderListener() { iPictoUploaderListener listener = new iPictoUploaderListener() {
int elements_uploaded = 0; int elements_uploaded = 0;
@Override @Override
public void success(boolean success) { public void success(boolean success, String msg) {
if (success) elements_uploaded++; if (success) elements_uploaded++;
else else {
GUITools.show_alert(context, R.string.upload_error,PictoUploader.this.picto.get_translation()); int errmsg =
msg.contains("Error: Picto already in student's vocabulary")
? R.string.upload_duplicated
: R.string.upload_error;
GUITools.show_alert(PCBcontext.getActivityContext(), errmsg, PictoUploader.this.picto.get_translation());
}
if (elements_uploaded == 2) { if (elements_uploaded == 2) {
PCBcontext.getPcbdb().deletePicto(local_img_id); PCBcontext.getPcbdb().deletePicto(local_img_id);
PictoUploader.this.picto.delete_bitmap(PCBcontext.getContext()); PictoUploader.this.picto.delete_bitmap(PCBcontext.getContext());
PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ADD, PictoUploader.this.picto)); PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ADD, PictoUploader.this.picto));
GUITools.show_alert(context, R.string.upload_ok,PictoUploader.this.picto.get_translation()); GUITools.show_alert(PCBcontext.getContext(), R.string.upload_ok,PictoUploader.this.picto.get_translation());
} }
} }
}; };
...@@ -213,7 +216,7 @@ public class PictoUploader { ...@@ -213,7 +216,7 @@ public class PictoUploader {
uploadTranslation(picto.get_id(), listener); uploadTranslation(picto.get_id(), listener);
} }
else { else {
GUITools.show_alert(context, R.string.upload_error, PictoUploader.this.picto.get_translation()); GUITools.show_alert(PCBcontext.getActivityContext(), R.string.upload_error, PictoUploader.this.picto.get_translation());
} }
} }
...@@ -262,6 +265,6 @@ public class PictoUploader { ...@@ -262,6 +265,6 @@ public class PictoUploader {
* Created by Fernando on 28/07/2016. * Created by Fernando on 28/07/2016.
*/ */
public static interface iPictoUploaderListener { public static interface iPictoUploaderListener {
void success(boolean success); void success(boolean success, String s);
} }
} }
...@@ -39,13 +39,14 @@ public class StudentTalk implements Emitter.Listener { ...@@ -39,13 +39,14 @@ public class StudentTalk implements Emitter.Listener {
Log.i(this.getClass().getName(), "raw Received message " +msg.toString()); Log.i(this.getClass().getName(), "raw Received message " +msg.toString());
int id=msg.getInt("id"); int id=msg.getInt("id");
String username=msg.getString("username"); String username=msg.getString("username");
String name=msg.getString("name");
String surname=msg.getString("surname"); String surname=msg.getString("surname");
String gender=msg.getString("gender"); String gender=msg.getString("gender");
String pic=msg.getString("pic"); String pic=msg.getString("pic");
String lang=msg.getString("lang"); String lang=msg.getString("lang");
String attributes=msg.getString("attributes"); String attributes=msg.getString("attributes");
User user=PCBcontext.getPcbdb().getCurrentUser(); User user=PCBcontext.getPcbdb().getCurrentUser();
User updatedUser=new User(id, username, user.get_pwd_stu(), username, surname, pic, gender, lang, attributes, User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname, pic, gender, lang, attributes,
user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(), user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(),
user.get_lang_sup(), user.get_tts_engine_sup(), user.get_office()); user.get_lang_sup(), user.get_tts_engine_sup(), user.get_office());
Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length); Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length);
......
...@@ -64,7 +64,7 @@ public final class PCBcontext { ...@@ -64,7 +64,7 @@ public final class PCBcontext {
throw new java.lang.AssertionError("init must be called once previously "); throw new java.lang.AssertionError("init must be called once previously ");
} }
Log.i(PCBcontext.class.getCanonicalName(), "User set at student " + student.get_name_stu()); Log.i(PCBcontext.class.getCanonicalName(), "User set at student " + student.get_name_stu()+ (student.is_supervisor() ? " with supervisor "+student.get_name_sup():"."));
wrapper.setToken(token); wrapper.setToken(token);
pcbdb = new PCBDBHelper(null, 2, student); pcbdb = new PCBDBHelper(null, 2, student);
pcbdb.user_online(token!=null); pcbdb.user_online(token!=null);
......
package com.yottacode.tools; package com.yottacode.tools;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.Point;
import android.util.Log; import android.util.Log;
import android.view.Display;
/** /**
* Created by Fernando on 01/04/2016. * Created by Fernando on 01/04/2016.
...@@ -35,4 +38,10 @@ public class GUITools { ...@@ -35,4 +38,10 @@ public class GUITools {
public static void show_alert(Context context, int resource_msg, String additional_msg) { public static void show_alert(Context context, int resource_msg, String additional_msg) {
show_alert(context, resource_msg, additional_msg,null); show_alert(context, resource_msg, additional_msg,null);
} }
public static Point getScreenSize(Activity context){
Display display = context.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return size;
}
} }
...@@ -301,6 +301,17 @@ BEGIN ...@@ -301,6 +301,17 @@ BEGIN
END END
;-- ;--
CREATE TRIGGER trg_update_supervisor
BEFORE UPDATE ON supervisor
FOR EACH ROW
WHEN NEW.id=-1
BEGIN
SELECT RAISE( ABORT,
'Null supervisor -1 is not updatable'
);
END
;--
DROP TRIGGER IF EXISTS trg_delete_collection DROP TRIGGER IF EXISTS trg_delete_collection
;-- ;--
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
<string name="notNewCats">Including new categories is not allowed</string> <string name="notNewCats">Including new categories is not allowed</string>
<string name="upload_error">It cannot be uploaded. It will be tried again later</string> <string name="upload_error">It cannot be uploaded. It will be tried again later</string>
<string name="upload_ok">It was correctly uploaded</string> <string name="upload_ok">It was correctly uploaded</string>
<string name="upload_duplicated">Pictogram is part of the collecion. Please, select a different one</string>
<!--online/offline status--> <!--online/offline status-->
<string name="pictogram_offline">Pictogram offline</string> <string name="pictogram_offline">Pictogram offline</string>
<string name="pictogram_online">Pictogram online</string> <string name="pictogram_online">Pictogram online</string>
...@@ -73,4 +74,9 @@ ...@@ -73,4 +74,9 @@
<string name="default_tts_engine">com.google.android.tts</string> <string name="default_tts_engine">com.google.android.tts</string>
<string name="default_tts_voice_male">en-gb-x-rjs#male_1-local</string> <string name="default_tts_voice_male">en-gb-x-rjs#male_1-local</string>
<string name="default_tts_voice_female">en-gb-x-fis#female_1-local</string> <string name="default_tts_voice_female">en-gb-x-fis#female_1-local</string>
<string name="crop_TextRequired">Please, introduce a message for the pictogram</string>
<string name="crop">Crop</string>
<string name="titleCropper">New pictogram</string>
<string name="uploadingImage">Uploading image</string>
</resources> </resources>
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
<string name="notNewCats">No puede añadir nuevas categorias</string> <string name="notNewCats">No puede añadir nuevas categorias</string>
<string name="upload_error">Pictograma local no pudo subirse al servidor. Se intentará más tarde</string> <string name="upload_error">Pictograma local no pudo subirse al servidor. Se intentará más tarde</string>
<string name="upload_ok">Pictograma local se subió correctamente al servidor</string> <string name="upload_ok">Pictograma local se subió correctamente al servidor</string>
<string name="upload_duplicated">Pictograma ya presente en la colección. Utilice otra imagen</string>
<!--online/offline status--> <!--online/offline status-->
<string name="pictogram_offline">Pictogram offline</string> <string name="pictogram_offline">Pictogram offline</string>
<string name="pictogram_online">Pictogram online</string> <string name="pictogram_online">Pictogram online</string>
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
<string name="notNewCats">No puede añadir nuevas categorias</string> <string name="notNewCats">No puede añadir nuevas categorias</string>
<string name="upload_error">No pudo subirse al servidor. Se intentará más adelante</string> <string name="upload_error">No pudo subirse al servidor. Se intentará más adelante</string>
<string name="upload_ok">Se subió correctamente al servidor</string> <string name="upload_ok">Se subió correctamente al servidor</string>
<string name="upload_duplicated">Pictograma ya presente en la colección. Utilice otra imagen</string>
<string name="title_activity_img_label">img_label</string> <string name="title_activity_img_label">img_label</string>
......
/build /build
/supervisor_tablet.iml supervisor_tablet.iml
/build /build
.iml
/tabletlibrary.iml
\ No newline at end of file
package com.yottacode.pictogram.tabletlibrary.cropper;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import com.yottacode.pictogram.tabletlibrary.R;
/**
* Created by German on 06/02/2017.
*/
public class EditPictoActivity extends Activity {
// Private Constants ///////////////////////////////////////////////////////////////////////////
public static final int EDIT_PICTO_REQUEST = 2288;
public static final String TRANSCRIPTION = "textPicto";
public static final String IMAGE_PICTO = "imagePicto";
public static final String IMAGE_ORIGIN = "imageOrigin";
public static final String IMAGE_ORIENTATION = "imageOrientation";
// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.edit_picto_layout);
// Initialize Views.
final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
final EditText legend = (EditText) findViewById(R.id.legend);
final Button okButton = (Button) findViewById(R.id.okButton);
final Button cancelButton = (Button) findViewById(R.id.cancelButton);
//final ImageView backgroundImage = (ImageView) findViewById(R.id.backgroundImage);
cropImageView.setFixedAspectRatio(true);
cropImageView.setGuidelines(2);
cropImageView.setAspectRatio(1,1);
final int orientation = getIntent().getExtras().getInt(EditPictoActivity.IMAGE_ORIENTATION);
final int origin = getIntent().getExtras().getInt(EditPictoActivity.IMAGE_ORIGIN);
String legendText = getIntent().getExtras().getString(EditPictoActivity.TRANSCRIPTION);
if(legendText != null) {
Log.i("DETALLES","Llega el intent al layout recortar, con texto: " + legendText);
legend.setText(legendText);
}else{
legend.setTextColor(Color.GRAY);
legend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
legend.setText("");
}
});
}
byte[] byteArray = getIntent().getByteArrayExtra(EditPictoActivity.IMAGE_PICTO);
Bitmap imagePicto = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
cropImageView.setImageBitmap(imagePicto);
/*byteArray = getIntent().getByteArrayExtra("imageBackground");
Bitmap imageBackground = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
backgroundImage.setImageBitmap(imageBackground);*/
okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Bitmap croppedImage = cropImageView.getCroppedImage(origin,orientation);
//Escalar y guardarla al server
Bitmap finalImage = null;
finalImage.createScaledBitmap(croppedImage,96,96,true);
Intent intent = getIntent();
intent.putExtra(EditPictoActivity.TRANSCRIPTION,legend.getText().toString());
Log.i("DETALLES","sale el intent al layout recortar, con texto: " + legend.getText().toString());
cropImageView.setImageBitmap(finalImage);
setResult(RESULT_OK,intent);
finish();
}
});
//Si cancela, volver a pictogram activity
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
/**
* To set background image for simulate the pictogramActivity
* @param bm
*/
/*public void setBackgroundImage(Bitmap bm){
ImageView backgroundImage = (ImageView) findViewById(R.id.backgroundImage);
backgroundImage.setImageBitmap(bm);
}*/
/**
* To set the image to crop
* @param bm
*/
public void setCropImage(Bitmap bm){
ImageView cropImage = (ImageView) findViewById(R.id.CropImageView);
cropImage.setImageBitmap(bm);
}
/**
* To set the image to crop
* @param text
*/
public void setLegendImage(String text){
EditText legend = (EditText) findViewById(R.id.legend);
legend.setText(text.toString());
}
}
package com.yottacode.pictogram.tabletlibrary.cropper; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
...@@ -15,18 +15,15 @@ import android.graphics.drawable.Drawable; ...@@ -15,18 +15,15 @@ import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle.Handle; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle.Handle;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
import com.yottacode.pictogram.tabletlibrary.cropper.util.HandleUtil; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.HandleUtil;
import com.yottacode.pictogram.tabletlibrary.cropper.util.PaintUtil; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.PaintUtil;
/** /**
...@@ -36,12 +33,7 @@ import com.yottacode.pictogram.tabletlibrary.cropper.util.PaintUtil; ...@@ -36,12 +33,7 @@ import com.yottacode.pictogram.tabletlibrary.cropper.util.PaintUtil;
*/ */
public class CropImageView extends ImageView { public class CropImageView extends ImageView {
// Private Constants ///////////////////////////////////////////////////////////////////////////
private static final int CAMERA_PIC_REQUEST = 1;
private static final int GALLERY_PIC_REQUEST = 2;
private static final int VERTICAL_ORIENTATION = 200;
private static final int HORIZONTAL_ORIENTATION = 300;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final String TAG = CropImageView.class.getName(); private static final String TAG = CropImageView.class.getName();
...@@ -253,10 +245,8 @@ public class CropImageView extends ImageView { ...@@ -253,10 +245,8 @@ public class CropImageView extends ImageView {
* Gets the cropped image based on the current crop window. * Gets the cropped image based on the current crop window.
* *
* @return a new Bitmap representing the cropped image * @return a new Bitmap representing the cropped image
* @param origin
* @param orientation
*/ */
public Bitmap getCroppedImage(int origin, int orientation) { public Bitmap getCroppedImage() {
final Drawable drawable = this.getDrawable(); final Drawable drawable = this.getDrawable();
if (drawable == null || !(drawable instanceof BitmapDrawable)) { if (drawable == null || !(drawable instanceof BitmapDrawable)) {
return null; return null;
...@@ -271,8 +261,8 @@ public class CropImageView extends ImageView { ...@@ -271,8 +261,8 @@ public class CropImageView extends ImageView {
final float scaleY = matrixValues[Matrix.MSCALE_Y]; //==1 final float scaleY = matrixValues[Matrix.MSCALE_Y]; //==1
// Extract the translation values. // Extract the translation values.
final float transX = (origin == CAMERA_PIC_REQUEST && orientation== HORIZONTAL_ORIENTATION ) ? matrixValues[Matrix.MTRANS_Y] : matrixValues[Matrix.MTRANS_X]; final float transX = matrixValues[Matrix.MTRANS_X];
final float transY = (origin == CAMERA_PIC_REQUEST && orientation== HORIZONTAL_ORIENTATION ) ? matrixValues[Matrix.MTRANS_X] : matrixValues[Matrix.MTRANS_Y]; final float transY = matrixValues[Matrix.MTRANS_Y];
final Bitmap originalBitmap = ((BitmapDrawable) drawable).getBitmap(); final Bitmap originalBitmap = ((BitmapDrawable) drawable).getBitmap();
/*Log.i("DETALLES","ScaleX: "+scaleX + "- ScaleY: "+scaleY); /*Log.i("DETALLES","ScaleX: "+scaleX + "- ScaleY: "+scaleY);
......
package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.PCBcontext;
import java.io.ByteArrayOutputStream;
/**
* Created by German on 06/02/2017.
*/
public class EditPictoActivity extends Activity {
// Private Constants ///////////////////////////////////////////////////////////////////////////
public static final int EDIT_PICTO_REQUEST = 2288;
public static final String PATH = "pathImage";
public static final String IMAGE_PICTO = "imagePicto";
private static final String LOG_PATH = EditPictoActivity.class.getName();
// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.edit_picto_layout);
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.75 ) - (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();
// Initialize Views.
final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
final EditText legend = (EditText) findViewById(R.id.edtLegend);
final Button okButton = (Button) findViewById(R.id.okButton);
final Button cancelButton = (Button) findViewById(R.id.cancelButton);
String transcription=getIntent().getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
cropImageView.setFixedAspectRatio(true);
cropImageView.setGuidelines(2);
cropImageView.setAspectRatio(1,1);
if(transcription != null && transcription.length()>0)
legend.setText(transcription);
legend.setHorizontallyScrolling(false);
legend.setMaxLines(1);
legend.setSingleLine(true);
//Obtener imagen del intent
byte[] byteArray = getIntent().getByteArrayExtra(EditPictoActivity.IMAGE_PICTO);
Bitmap imagePicto = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
cropImageView.setImageBitmap(imagePicto);
cropImageView.setMaxWidth(imagePicto.getWidth());
cropImageView.setMaxHeight(imagePicto.getHeight());
if (transcription!=null && transcription.length()>0)
legend.setText(transcription);
//Gestion de botones
okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (legend.getText().toString().trim().length()>0) {
final Bitmap croppedImage = cropImageView.getCroppedImage();
//Escalar imagen
Bitmap finalImage = croppedImage.createScaledBitmap(croppedImage, 96, 96, true);
//Guardar imagen en galeria y obtener la ruta
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
finalImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String title = getResources().getString(R.string.app_name) + ' ' + legend.getText().toString();
String path = MediaStore.Images.Media.insertImage(PCBcontext.getContext().getContentResolver(), finalImage, title, null);
path = getRealPathFromURI(Uri.parse(path));
Log.i(LOG_PATH, " New image " + title + " saved at " + path);
Intent intent = getIntent(); //Mandar a pictogram activity el path y el texto de la imagen
intent.putExtra(PATH, path);
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString());
cropImageView.setImageBitmap(finalImage);
setResult(RESULT_OK, intent);
finish(); //Termina la actividad de editar
}
else Toast.makeText(getBaseContext(),R.string.crop_TextRequired, Toast.LENGTH_LONG).show();
}
});
//Si cancela, volver a pictogram activity
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
setResult(RESULT_CANCELED,getIntent());
}
});
}
public String getRealPathFromURI(Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = this.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
}
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
* governing permissions and limitations under the License. * governing permissions and limitations under the License.
*/ */
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
/** /**
* Enum representing an edge in the crop window. * Enum representing an edge in the crop window.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge;
/** /**
* Simple class to hold a pair of Edges. * Simple class to hold a pair of Edges.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
/** /**
* HandleHelper class to handle the center handle. * HandleHelper class to handle the center handle.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.EdgePair; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.EdgePair;
/** /**
* HandleHelper class to handle corner Handles (i.e. top-left, top-right, bottom-left, and * HandleHelper class to handle corner Handles (i.e. top-left, top-right, bottom-left, and
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
/** /**
* Enum representing a pressable, draggable Handle on the crop window. * Enum representing a pressable, draggable Handle on the crop window.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.EdgePair; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.EdgePair;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
/** /**
* Abstract helper class to handle operations on a crop window Handle. * Abstract helper class to handle operations on a crop window Handle.
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
/** /**
* Handle helper class to handle horizontal handles (i.e. top and bottom handles). * Handle helper class to handle horizontal handles (i.e. top and bottom handles).
......
package com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.edge.Edge; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.edge.Edge;
import com.yottacode.pictogram.tabletlibrary.cropper.util.AspectRatioUtil; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.AspectRatioUtil;
/** /**
* HandleHelper class to handle vertical handles (i.e. left and right handles). * HandleHelper class to handle vertical handles (i.e. left and right handles).
......
package com.yottacode.pictogram.tabletlibrary.cropper.util; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
......
package com.yottacode.pictogram.tabletlibrary.cropper.util; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util;
import android.graphics.PointF; import android.graphics.PointF;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.yottacode.pictogram.tabletlibrary.cropper.cropwindow.handle.Handle; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.cropwindow.handle.Handle;
/** /**
* Utility class to perform basic operations with Handles. * Utility class to perform basic operations with Handles.
......
package com.yottacode.pictogram.tabletlibrary.cropper.util; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util;
public class MathUtil { public class MathUtil {
......
package com.yottacode.pictogram.tabletlibrary.cropper.util; package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Paint; import android.graphics.Paint;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<string name="session_loading">Downloading instructions</string> <string name="session_loading">Downloading instructions</string>
<string name="session_empty">Student without any method</string> <string name="session_empty">Student without any method</string>
<string name="session_notclosed">Last session was not closed. Please close from </string> <string name="session_notclosed">Last session was not closed. Please close from </string>
<string name="session_closed_ok">Session upload ok</string> <string name="session_closed_ok">Session uploupload ok</string>
<string name="session_closed_fail">Session not uploaded. Please, try it from</string> <string name="session_closed_fail">Session not uploaded. Please, try it from</string>
<string name="session_pause_error">Pause session failed</string> <string name="session_pause_error">Pause session failed</string>
<string name="session_noinet">No server conexion. Internet conexion is available?</string> <string name="session_noinet">No server conexion. Internet conexion is available?</string>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<!---session--> <!---session-->
<string name="session_method">Método</string> <string name="session_method">Método</string>
<string name="session_insrtuction">Instrucción</string> <string name="session_instruction">Instrucción</string>
<string name="session_header">Seleccion de método e instrucción</string> <string name="session_header">Seleccion de método e instrucción</string>
<string name="session_error">Error de conexión</string> <string name="session_error">Error de conexión</string>
<string name="session_noinstructions">Alumno sin ninguna instrucción asignada. Por favor, asigne al menos una instrucción al alumno desde Pictogram Web</string> <string name="session_noinstructions">Alumno sin ninguna instrucción asignada. Por favor, asigne al menos una instrucción al alumno desde Pictogram Web</string>
...@@ -35,13 +35,12 @@ ...@@ -35,13 +35,12 @@
<string name="session_eval_notevuated">no evaluado</string> <string name="session_eval_notevuated">no evaluado</string>
<string name="session_eval_discarded">inválido</string> <string name="session_eval_discarded">inválido</string>
<string name="crop">Recortar</string> <string name="crop">Recortar</string>
<string name="titleCropper">Editar Picto</string> <string name="titleCropper">Nuevo Pictograma</string>
<string name="croppedImageDesc">Vista Previa</string> <string name="crop_TextRequired">Por favor, introduzca una leyenda para el pictograma</string>
<string name="cancel">Cancelar</string> <string name="legendText">Leyenda:</string>
<string name="accept">Aceptar</string>
<string name="legendText">Leyenda</string>
<string name="dialogCamera">Hacer Foto</string> <string name="dialogCamera">Hacer Foto</string>
<string name="dialogGallery">Seleccionar de Galería</string> <string name="dialogGallery">Seleccionar de Galería</string>
<string name="dialogTitle">Seleccionar Método</string> <string name="dialogTitle">Seleccionar Método</string>
<string name="dialogCancel">Cancelar</string> <string name="dialogCancel">Cancelar</string>
<string name="uploadingImage">Subiendo imagen al servidor</string>
</resources> </resources>
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
<color name="white_translucent">#AAFFFFFF</color> <color name="white_translucent">#AAFFFFFF</color>
<color name="black_translucent">#b4000000</color> <color name="black_translucent">#b4000000</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="gray_blue">#FF78909C</color>
<color name="blue_light">#FF40C4FF</color>
<color name="gray">#FF727272</color>
<color name="border">@color/white_translucent</color> <color name="border">@color/white_translucent</color>
<color name="guideline">@color/white_translucent</color> <color name="guideline">@color/white_translucent</color>
......
...@@ -44,15 +44,16 @@ ...@@ -44,15 +44,16 @@
<string name="dialogGallery">Seleccionar de Galería</string> <string name="dialogGallery">Seleccionar de Galería</string>
<string name="dialogCancel">Cancelar</string> <string name="dialogCancel">Cancelar</string>
<!-- Cropper --> <!-- Cropper -->
<string name="legendText">Leyenda</string> <string name="legendText">Leyenda:</string>
<string name="titleCropper">Editar Picto</string>
<string name="fixedAspectRatio">fixedAspectRatio =\u0020</string> <string name="fixedAspectRatio">fixedAspectRatio =\u0020</string>
<string name="aspectRatioXHeader">aspectRatioX =\u0020</string> <string name="aspectRatioXHeader">aspectRatioX =\u0020</string>
<string name="aspectRatioYHeader">aspectRatioY =\u0020</string> <string name="aspectRatioYHeader">aspectRatioY =\u0020</string>
<string name="showGuidelines">showGuidelines =\u0020</string> <string name="showGuidelines">showGuidelines =\u0020</string>
<string name="accept">Aceptar</string> <string name="crop">Recortar</string>
<string name="cancel">Cancel</string> <string name="titleCropper">Nuevo Pictograma</string>
<string name="croppedImageDesc">Vista Previa</string> <string name="crop_TextRequired">Por favor, introduzca una leyenda para el pictograma</string>
<string name="uploadingImage">Subiendo imagen al servidor</string>
<string-array name="showGuidelinesArray"> <string-array name="showGuidelinesArray">
<item>Off</item> <item>Off</item>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":tabletlibrary" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4"> <module external.linked.project.id=":tabletlibrary" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" version="4">
<component name="FacetManager"> <component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle"> <facet type="android-gradle" name="Android-Gradle">
<configuration> <configuration>
<option name="GRADLE_PROJECT_PATH" value=":tabletlibrary" /> <option name="GRADLE_PROJECT_PATH" value=":tabletlibrary" />
</configuration> </configuration>
</facet> </facet>
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
<facet type="android" name="Android"> <facet type="android" name="Android">
<configuration> <configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" /> <option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" /> <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" /> <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks> <afterSyncTasks>
...@@ -25,14 +20,13 @@ ...@@ -25,14 +20,13 @@
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" /> <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" /> <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" /> <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
<option name="PROJECT_TYPE" value="1" /> <option name="LIBRARY_PROJECT" value="true" />
</configuration> </configuration>
</facet> </facet>
</component> </component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false"> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" /> <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" /> <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
...@@ -53,6 +47,7 @@ ...@@ -53,6 +47,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
...@@ -60,6 +55,7 @@ ...@@ -60,6 +55,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
...@@ -67,6 +63,7 @@ ...@@ -67,6 +63,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<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/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
...@@ -74,6 +71,7 @@ ...@@ -74,6 +71,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<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/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
...@@ -100,10 +98,16 @@ ...@@ -100,10 +98,16 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/24.2.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/24.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/typedefs.txt" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" /> <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content> </content>
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
...@@ -119,6 +123,7 @@ ...@@ -119,6 +123,7 @@
<orderEntry type="library" exported="" name="support-vector-drawable-24.2.1" level="project" /> <orderEntry type="library" exported="" name="support-vector-drawable-24.2.1" level="project" />
<orderEntry type="library" exported="" name="support-core-utils-24.2.1" level="project" /> <orderEntry type="library" exported="" name="support-core-utils-24.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="okhttp-ws-2.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-base-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-base-9.2.1" level="project" />
<orderEntry type="library" exported="" name="socket.io-client-0.5.0" level="project" /> <orderEntry type="library" exported="" name="socket.io-client-0.5.0" level="project" />
...@@ -145,4 +150,4 @@ ...@@ -145,4 +150,4 @@
<orderEntry type="library" exported="" scope="TEST" name="json-20090211" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="json-20090211" 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" />
</component> </component>
</module> </module>
\ No newline at end of file
/build /build
/watch.iml .iml
\ No newline at end of file
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
android:screenOrientation="landscape" /> android:screenOrientation="landscape" />
<activity <activity
android:name="com.yottacode.pictogram.tabletlibrary.cropper.EditPictoActivity" android:name="com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity"
android:exported="true" android:exported="true"
android:label="@string/app_name" android:label="@string/app_name"
android:launchMode="singleInstance" android:launchMode="singleInstance"
......
...@@ -243,16 +243,107 @@ module.exports = { ...@@ -243,16 +243,107 @@ module.exports = {
}) })
.catch(() => res.serverError()); .catch(() => res.serverError());
function getCategories(id_cat){ // function getCategories(id_cat){
PictoCat // PictoCat
.find({select: ['id'], id_supercat: id_cat }) // .find({select: ['id'], id_supercat: id_cat })
.then(function (categories) { // .then(function (categories) {
console.log(categories); // console.log(categories);
return categories; // return categories;
// })
// .catch(function (err) {
// throw err;
// });
// }
},
/**
* Return own or public pictos using a search string from category
* and subcategories using the language of the specified supervisor.
* @param {request} req {} (with supervisorId and categoryId as url parameters)
* @param {response} res
* [
* {
* expressions: [
* // There should be just one expression per picto
* // with the language being used by the supervisor
* {
* id: 1234,
* lang: 'es-es',
* text: 'nacimiento',
* picto: 23
* }
* ],
* source: 1,
* owner: null,
* id: 23,
* uri: 'picto/uri.jpg',
* category: 41
* }
* ]
*/
fromSearch: function (req, res) {
Supervisor.findOne({ id: req.params.id }).then(function (supervisor) {
if (supervisor) {
if (req.params.id_cat == 0){ //Search in all categories
getPictos(0, supervisor.lang, supervisor.id);
}else{//Get selected category and subcategories
PictoCat
.find({select: ['id'], id_supercat: req.params.id_cat })
.then(function (categories) {
var filtered = [Number(req.params.id_cat)]; //Get returned ID
for(var i =0; i<categories.length;i++){
filtered.push(categories[i].id);
}
getPictos(filtered, supervisor.lang, supervisor.id);
})
.catch(function (err) {
throw err;
});
}
} else {
return res.badRequest();
}
})
.catch(() => res.serverError());
//
// Get pictos within specified categories
//
function getPictos(categories, lang, sup_id){
var l = [];
var fs = require('fs');
//Only fetch owned or public pictos
var params = {or: [{owner: null}, {owner: sup_id}], source: req.params.source};
if(typeof categories == "object" ){ //Is an array
params = { or: [{owner: null}, {owner: sup_id}], category: categories };
}
Picto.find().where(params)
.paginate({page: req.params.page, limit: req.params.limit})
.populate('expressions', {lang: lang, text: { like: '%'+req.params.text+'%'}})
.then(function (pictos) {
async.eachSeries(pictos, function(picto, next_cb) {
// check picto has expressions associated in student language
if (picto.expressions.length == 0 || picto.expressions[0].text.length == 0)
return next_cb();
// check picto image is available
picto.imageFileExists((found) => {
if (found) {
l.push(picto);
next_cb();
}
else
next_cb();
});
},
function (err) { // loop has end
if (err) throw err;
sails.log.debug(pictos.length + " pictos sent for category " + req.params.id_cat + " in language " + lang);
return res.ok(l);
}); // end async.eachSeries
}) })
.catch(function (err) { .catch(() => res.badRequest());
throw err;
});
} }
}, },
......
...@@ -391,7 +391,9 @@ ...@@ -391,7 +391,9 @@
"view": "View", "view": "View",
"voice": "Voice", "voice": "Voice",
"warning_last_session_bad": "Last session was interrupted. Please, you must evaluate last tries and press 'close seesion' button", "warning_last_session_bad": "Last session was interrupted. Please, you must evaluate last tries and press 'close seesion' button",
"warning_no_pictos_found": "No pictograms found with specified keyword",
"warning_no_tablet_online":"No Pictogran Tablet online detected", "warning_no_tablet_online":"No Pictogran Tablet online detected",
"warning_two_characters":"Must type at least two characters",
"woman": "Woman", "woman": "Woman",
"year_totals": "Year totals", "year_totals": "Year totals",
"yes": "Yes", "yes": "Yes",
......
...@@ -392,7 +392,9 @@ ...@@ -392,7 +392,9 @@
"view": "Vista", "view": "Vista",
"voice": "Voz", "voice": "Voz",
"warning_last_session_bad": "La última sesión no se cerró correctamente. Por favor, evalúe los ensayos y pulse 'cerrar sesión' ", "warning_last_session_bad": "La última sesión no se cerró correctamente. Por favor, evalúe los ensayos y pulse 'cerrar sesión' ",
"warning_no_pictos_found": "No se encontraron pictogramas con las palabras introducidas",
"warning_no_tablet_online":"No se detectó ningún usuario de Pictogram Tablet online", "warning_no_tablet_online":"No se detectó ningún usuario de Pictogram Tablet online",
"warning_two_characters":"Debe introducir al menos dos caracteres",
"woman": "Mujer", "woman": "Mujer",
"year_totals": "Totales año", "year_totals": "Totales año",
"yes": "Sí", "yes": "Sí",
......
...@@ -17,7 +17,8 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -17,7 +17,8 @@ dashboardControllers.controller('AddPictoCtrl', function (
ngToast, ngToast,
config, config,
supervisor, supervisor,
student) { student,
onlyOwn) {
$scope.source = 'symbolstx'; $scope.source = 'symbolstx';
$scope.pictos = []; // Pictos to show with infinite sroll $scope.pictos = []; // Pictos to show with infinite sroll
...@@ -26,36 +27,41 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -26,36 +27,41 @@ dashboardControllers.controller('AddPictoCtrl', function (
$scope.symbolstxCats = []; $scope.symbolstxCats = [];
$scope.breadcrumbs = []; $scope.breadcrumbs = [];
$scope.loadingCatPictos = false; $scope.loadingCatPictos = false;
$scope.radioModel = 'Middle'; $scope.radioModel = 'Middle';
$scope.onlyOwn = onlyOwn;
$scope.breadcrumbs.push({ /*
id: 0, * Get data about SymbolStix
exp: 'Inicio', */
glyphicon: 'glyphicon glyphicon-home' if (!onlyOwn) { // only if the modal will allow to select SymbolStix pictos
}); $scope.breadcrumbs.push({
id: 0,
// Request of general pictos categories (symbolstx) exp: 'Inicio',
$http.get(config.backend + '/sup/' + supervisor.id + '/pic_categories/0') glyphicon: 'glyphicon glyphicon-home'
.success(function (data) {
$scope.symbolstxCats = data;
})
.error(function () {
$translate('error_loading_pictos').then(function (translation) {
ngToast.danger({ content: translation });
}); });
});
// Request of general pictos categories (symbolstx)
// Request page 1 pictos (symbolstx) $http.get(config.backend + '/sup/' + supervisor.id + '/pic_categories/0')
$http.get(config.backend + '/sup/' + supervisor.id + '/pic_fromSymbolStx/page/1/limit/'+$scope.limit) .success(function (data) {
.success(function (data) { $scope.symbolstxCats = data;
$scope.pictos = data; })
}) .error(function () {
.error(function () { $translate('error_loading_pictos').then(function (translation) {
$translate('error_loading_pictos').then(function (translation) { ngToast.danger({ content: translation });
ngToast.danger({ content: translation }); });
}); });
});
// Request page 1 pictos (symbolstx)
$http.get(config.backend + '/sup/' + supervisor.id + '/pic_fromSymbolStx/page/1/limit/'+$scope.limit)
.success(function (data) {
$scope.pictos = data;
})
.error(function () {
$translate('error_loading_pictos').then(function (translation) {
ngToast.danger({ content: translation });
});
});
}
// //
// Load pictos from a category // Load pictos from a category
...@@ -88,13 +94,11 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -88,13 +94,11 @@ dashboardControllers.controller('AddPictoCtrl', function (
}; };
// //
// Load pictos from owned by the actual supervisor // Load pictos owned by the actual supervisor
// //
$scope.load_own_pictos = function () { $scope.load_own_pictos = function () {
$scope.source = 'ownpictos'; $scope.source = 'ownpictos';
$('#own_group').fadeIn();
$http.get(config.backend + '/sup/' + supervisor.id + '/pictos') $http.get(config.backend + '/sup/' + supervisor.id + '/pictos')
.success(function (data) { .success(function (data) {
if (data) { if (data) {
...@@ -208,7 +212,7 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -208,7 +212,7 @@ dashboardControllers.controller('AddPictoCtrl', function (
picto.expressions = []; picto.expressions = [];
$scope.open_exp(picto, () => { $scope.open_exp(picto, () => {
$scope.pictos.push(picto); $scope.pictos.push(picto);
$scope.load_own_pictos(); load_own_pictos();
cb(); cb();
}); });
}); });
...@@ -238,14 +242,16 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -238,14 +242,16 @@ dashboardControllers.controller('AddPictoCtrl', function (
} }
} }
// websocket emit vocabulary delete action if (!$scope.onlyOwn) {
io.socket.post('/stu/vocabulary', { // websocket emit vocabulary delete action
action: 'delete', io.socket.post('/stu/vocabulary', {
attributes: { action: 'delete',
id_stu: student.id, attributes: {
stu_picto: pictoId id_stu: student.id,
} stu_picto: pictoId
}, function () {}); }
}, function () {});
}
}) })
.error(function () {}); .error(function () {});
...@@ -288,12 +294,16 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -288,12 +294,16 @@ dashboardControllers.controller('AddPictoCtrl', function (
//Triggered when scrolling to bottom //Triggered when scrolling to bottom
$scope.scroll = function(){ $scope.scroll = function(){
if ($scope.onlyOwn)
return;
$scope.loadingCatPictos = true; $scope.loadingCatPictos = true;
$scope.page += 1; $scope.page += 1;
var request = ""; var request = "";
if($scope.breadcrumbs.length == 1){ if($scope.breadcrumbs.length == 1) {
//Request page X from all pictos (symbolstx) //Request page X from all pictos (symbolstx)
request = config.backend + '/sup/' + supervisor.id + request = config.backend + '/sup/' + supervisor.id +
'/pic_fromSymbolStx/page/'+$scope.page+'/limit/'+$scope.limit; '/pic_fromSymbolStx/page/'+$scope.page+'/limit/'+$scope.limit;
...@@ -313,5 +323,63 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -313,5 +323,63 @@ dashboardControllers.controller('AddPictoCtrl', function (
}); });
$scope.loadingCatPictos = false; $scope.loadingCatPictos = false;
}); });
} };
//
// Search srch_term_picto in owned or public pictos
//
$scope.search = function() {
if ($scope.onlyOwn)
return;
$scope.page=1; // Reset pagination
var length = $scope.srch_term_picto == undefined ? 0 : $scope.srch_term_picto.length;
if(length <2){ //Check the word length
$scope.alert = { type: 'warning', msg: 'warning_two_characters', show: true };
}else{
var request = "";
var source = 1;
$scope.closeAlert();
$scope.loadingCatPictos = true;
//category to look in
var category = $scope.breadcrumbs[$scope.breadcrumbs.length-1].id;
if($scope.source == "ownpictos"){
source = 2;
category = 0;
}
request = config.backend + '/sup/' + supervisor.id +
'/pic_fromSearch/'+$scope.srch_term_picto+'/category/'+category+
'/page/'+$scope.page+'/limit/'+$scope.limit+'/source/'+source;
// Add Search to breadcrumbs
if($scope.breadcrumbs[$scope.breadcrumbs.length-1].id != 999){
$scope.breadcrumbs.push({
id: 999,
exp: "filter",
glyphicon: 'glyphicon glyphicon-chevron-right'
});
}
$scope.symbolstxCats = [];
$http.get(request)
.success(function (data) {
$scope.pictos = data;
if(data.length == 0){
$scope.alert = { type: 'warning', msg: 'warning_no_pictos_found', show: true };
}
$scope.loadingCatPictos = false;
})
.error(function () {
$translate('error_loading_pictos').then(function (translation) {
ngToast.danger({ content: translation });
});
$scope.loadingCatPictos = false;
});
}
};
if (onlyOwn)
$scope.load_own_pictos();
}); });
...@@ -359,9 +359,13 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -359,9 +359,13 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}, },
supervisor: function () { supervisor: function () {
return $scope.user; return $scope.user;
},
onlyOwn: function () {
return false;
} }
} }
}); });
// Returned data from the modal window // Returned data from the modal window
modalInstance.result.then(function (pictoId) { modalInstance.result.then(function (pictoId) {
......
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
<button type="button" class="close" ng-click="close()"> <button type="button" class="close" ng-click="close()">
<span aria-hidden="true">&times;</span><span class="sr-only" translate>close</span> <span aria-hidden="true">&times;</span><span class="sr-only" translate>close</span>
</button> </button>
<h4 class="modal-title" id="myModalLabel" translate>add_picto</h4> <h4 class="modal-title" id="myModalLabel" translate ng-show="!onlyOwn">add_picto</h4>
<h4 class="modal-title" id="myModalLabel" translate ng-show="onlyOwn">own_pictos</h4>
<hr> <hr ng-show="!onlyOwn">
<div class="btn-group"> <div class="btn-group" ng-show="!onlyOwn">
<button class="btn btn-default" btn-radio="'symbolstx'" ng-model="source" ng-click="open_category_from_bc('0')"> <button class="btn btn-default" btn-radio="'symbolstx'" ng-model="source" ng-click="open_category_from_bc('0')">
<span class="glyphicon glyphicon-th"></span> SymbolStix <span class="glyphicon glyphicon-th"></span> SymbolStix
</button> </button>
...@@ -17,15 +18,15 @@ ...@@ -17,15 +18,15 @@
<span class="glyphicon glyphicon-picture"></span> {{ 'own_pictos' | translate }} <span class="glyphicon glyphicon-picture"></span> {{ 'own_pictos' | translate }}
</button> </button>
</div> </div>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div ng-show="source == 'symbolstx'" class="panel panel-default" id="bread_and_categories">
<div id="bread_and_categories" ng-show="source == 'symbolstx' && !onlyOwn" class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<div class="pull-left" ng-repeat="b in breadcrumbs"> <div class="pull-left" ng-repeat="b in breadcrumbs">
<a ng-click="open_category_from_bc(b.id)"> <a ng-click="open_category_from_bc(b.id)">
<span class="{{b.glyphicon}}"></span> {{ b.exp }} <span class="{{b.glyphicon}}"></span> {{ b.exp | translate}}
</a> </a>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
...@@ -37,89 +38,62 @@ ...@@ -37,89 +38,62 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div><!-- /bread_and_categories -->
<div> <div>
<alert ng-show="alert.show" ng-model="alert" type="{{alert.type}}" close="closeAlert()">{{alert.msg}}</alert> <alert ng-show="alert.show" ng-model="alert" type="{{alert.type}}" close="closeAlert()">{{alert.msg | translate}}</alert>
</div> </div>
<div class="row" ng-show="source != 'newfile'" > <div id="collections" class="col-md-12 category-collection"
<div id="collections" class="col-md-12 category-collection" ng-class="{ 'category-collection-loading': loadingCatPictos }"
ng-class="{ 'category-collection-loading': loadingCatPictos }" data-loading="{{ 'loading_pictos' | translate }}">
data-loading="{{ 'loading_pictos' | translate }}"> <form ng-submit="search()" ng-show="!onlyOwn">
<div class="input-group" id="search_pictos_box"> <div class="input-group" id="search_pictos_box">
<input type="text" class="form-control" placeholder="{{ 'filter' | translate }}" ng-model="srch_term_picto" id="srch_term_picto"> <input type="text" class="form-control" placeholder="{{ 'filter' | translate }}"
<span class="input-group-addon glyphicon glyphicon-search" id="basic-addon2" aria-hidden="true"></span> id="srch_term_picto" name="srch_term_picto" ng-model="srch_term_picto">
</div> <span class="input-group-btn">
<div ng-show="source == 'ownpictos'" class="input-group"> <button type="submit" class="btn btn-primary">
<button class="btn btn-success" ngf-select ng-model="picFile" accept="image/*" ngf-change="addOwnPicto()"> <i class="fa fa-search" aria-hidden="true"></i> {{ 'search' | translate }}
<span class="glyphicon glyphicon-folder-open"></span> {{ 'new_img' | translate }} </button>
</label> </span>
</div> </div>
<!-- Galería de pictos --> </form>
<div id="clearfix-infiniteScroll-parent" infinite-scroll="scroll()" <div ng-show="source == 'ownpictos'" class="input-group">
infinite-scroll-container="'#collections'"> <button class="btn btn-success" ngf-select ng-model="picFile" accept="image/*" ngf-change="addOwnPicto()">
<div <span class="glyphicon glyphicon-folder-open"></span> {{ 'new_img' | translate }}
class="picto_peq pull-left" </button>
ng-repeat="p in pictos | filter:srch_term_picto" > </div>
<img ng-src="{{p.uri}}" popover="{{p.expressions[0].text}}" popover-trigger="mouseenter" /> <!-- Galería de pictos -->
<div id="clearfix-infiniteScroll-parent" infinite-scroll="scroll()"
infinite-scroll-container="'#collections'">
<div
class="picto_peq pull-left"
ng-repeat="p in pictos" >
<img ng-src="{{p.uri}}" popover="{{p.expressions[0].text}}" popover-trigger="mouseenter" />
<div class="picto_options">
<!-- Options to remove picto (Only for own pictos) --> <!-- Options to remove picto (Only for own pictos) -->
<div class="picto_options" ng-show="source == 'ownpictos'"> <a ng-click="remove_own_picto(p.id)" class="picto_remove" title="{{ 'delete' | translate}}" ng-show="source == 'ownpictos'">
<a ng-click="remove_own_picto(p.id)" class="picto_remove" title="{{ 'delete' | translate}}"> <span class="color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span>
<span class="color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span> </a>
</a> <a ng-show="!onlyOwn"
</div> ng-click="close(p.id)"
<div class="picto_options"> class="picto_add"
<a ng-click="remove_own_picto(p.id)" class="picto_remove" title="{{ 'delete' | translate}}"> title="{{ 'add_picto' | translate}}">
<a <span class="color_green glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
ng-click="close(p.id)" </a>
class="picto_add"
title="{{ 'add_picto' | translate}}">
<i class="color_green glyphicon glyphicon-plus-sign" aria-hidden="true"></i>
</a>
</a>
</div>
</div> </div>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
</div>
</div>
<!-- crop view --> </div><!-- /collections -->
<div id="crop_area" ng-show="source == 'newfile'">
<div class="row"> </div><!-- /row -->
<div class="col-md-8">
<div ngf-drop ng-model="picFile" ngf-pattern="image/*" class="cropArea">
<img-crop
image="picFile | ngfDataUrl"
result-image="croppedDataUrl" ng-init="croppedDataUrl=''"
area-type="square"
result-image-size="200"
>
</img-crop>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<img ng-src="{{ croppedDataUrl }}" />
</div>
<div class="form-group">
<button class="btn btn-default" ng-click="upload(croppedDataUrl, picFile.name)" ng-model="picFile" accept="image/*">
<span class="glyphicon glyphicon-upload"></span> {{ 'upload_image' | translate }}
</button>
</div>
<div class="form-group">
<span class="progress" ng-show="progress >= 0">
<div style="width:{{progress}}%" ng-bind="progress + '%'"></div>
</span>
</div>
</div>
</div>
</div>
</div> <!-- /modal-body --> </div> <!-- /modal-body -->
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-click="cancel()">{{ 'close' | translate }}</button> <button class="btn btn-primary" ng-click="cancel()">{{ 'close' | translate }}</button>
</div> </div>
</div> </div>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<div class="row"> <div class="row">
<div class="col-xs-6"> <div class="col-xs-6">
<div class="input-group" id="add_label" > <div class="input-group" id="add_label" >
<span class="input-group-addon glyphicon glyphicon-comment" aria-hidden="true"></span> <span class="input-group-addon"><span class="glyphicon glyphicon-comment" aria-hidden="true"></span></span>
<input type="text" class="form-control" ng-model="studentPicto.attributes.expression" /> <input type="text" class="form-control" ng-model="studentPicto.attributes.expression" />
</div> </div>
</div> </div>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<form ng-submit="save()"> <form ng-submit="save()">
<div id="add_label" class="input-group"> <div id="add_label" class="input-group">
<span class="input-group-addon glyphicon glyphicon-comment" aria-hidden="true"></span> <span class="input-group-addon"><span class="glyphicon glyphicon-comment" aria-hidden="true"></span></span>
<input type="text" class="form-control" ng-model="expression" autofocus/> <input type="text" class="form-control" ng-model="expression" autofocus/>
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-success" type="submit" translate>save</button> <button class="btn btn-success" type="submit" translate>save</button>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<li class="list-group-item clearfix"> <li class="list-group-item clearfix">
<form ng-submit="add()"> <form ng-submit="add()">
<div id="add_label" class="input-group"> <div id="add_label" class="input-group">
<span class="input-group-addon glyphicon glyphicon-tag" aria-hidden="true"></span> <span class="input-group-addon"><span class="glyphicon glyphicon-tag" aria-hidden="true"></span></span>
<input type="text" class="form-control" ng-model="tagToAdd" /> <input type="text" class="form-control" ng-model="tagToAdd" />
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-success" type="submit" translate>add</button> <button class="btn btn-success" type="submit" translate>add</button>
......
...@@ -5,7 +5,16 @@ ...@@ -5,7 +5,16 @@
//----------------------- //-----------------------
// Supervisor Controller // Supervisor Controller
//----------------------- //-----------------------
dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl($scope, $window, $location, IOService, $modal, $translate) { dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
$scope,
$http,
config,
$window,
$location,
IOService,
$modal,
$translate
) {
// Restore user data from session // Restore user data from session
var user = JSON.parse($window.sessionStorage.user); var user = JSON.parse($window.sessionStorage.user);
...@@ -35,4 +44,28 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl($scope ...@@ -35,4 +44,28 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl($scope
} }
}); });
//
// Own Pictos
//
$scope.own_pictos = function () {
var modalInstance = $modal.open({
animation: true,
templateUrl: 'modules/student/views/addpicto.html',
controller: 'AddPictoCtrl',
size: 'lg',
resolve: {
student: function () {
return null;
},
supervisor: function () {
return $scope.user;
},
onlyOwn: function () {
return true;
}
}
});
}
}); });
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
</a> </a>
</li> </li>
<li> <li>
<a ng-click="own_pictos()" class="pointer" role="menuitem" tabindex="0" href="">
<i class="glyphicon glyphicon-picture" aria-hidden="true"></i>
{{ 'own_pictos' | translate }}
</a>
</li>
<li>
<a class="pointer" role="menuitem" tabindex="0" href="/app/#/setup"> <a class="pointer" role="menuitem" tabindex="0" href="/app/#/setup">
<i class="glyphicon glyphicon-cog" aria-hidden="true"></i> <i class="glyphicon glyphicon-cog" aria-hidden="true"></i>
{{ 'setup' | translate }} {{ 'setup' | translate }}
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<div class="col-xs-4"> <div class="col-xs-4">
<div class=" input-group"> <div class=" input-group">
<input type="text" ng-model="search_sups" id="search_sups" placeholder="{{ 'filter' | translate }}" class="form-control" aria-describedby="basic-addon2"> <input type="text" ng-model="search_sups" id="search_sups" placeholder="{{ 'filter' | translate }}" class="form-control" aria-describedby="basic-addon2">
<span class="input-group-addon glyphicon glyphicon-search" id="basic-addon2" aria-hidden="true"></span> <span class="input-group-addon"><span class="glyphicon glyphicon-search" id="basic-addon2" aria-hidden="true"></span></span>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -75,7 +75,8 @@ module.exports.policies = { ...@@ -75,7 +75,8 @@ module.exports.policies = {
categories: ['tokenAuth'], categories: ['tokenAuth'],
fromcategory: ['tokenAuth'], fromcategory: ['tokenAuth'],
fromSymbolStx: ['tokenAuth'], fromSymbolStx: ['tokenAuth'],
fromCatSubcat: ['tokenAuth'] fromCatSubcat: ['tokenAuth'],
fromSearch: ['tokenAuth']
}, },
ServerController: { ServerController: {
......
...@@ -108,6 +108,7 @@ module.exports.routes = { ...@@ -108,6 +108,7 @@ module.exports.routes = {
'GET /sup/:id/pic_fromcategory/:id_cat': 'PictoController.fromcategory', 'GET /sup/:id/pic_fromcategory/:id_cat': 'PictoController.fromcategory',
'GET /sup/:id/pic_fromSymbolStx/page/:page/limit/:limit': 'PictoController.fromSymbolStx', 'GET /sup/:id/pic_fromSymbolStx/page/:page/limit/:limit': 'PictoController.fromSymbolStx',
'GET /sup/:id/pic_fromCatSubcat/category/:id_cat/page/:page/limit/:limit': 'PictoController.fromCatSubcat', 'GET /sup/:id/pic_fromCatSubcat/category/:id_cat/page/:page/limit/:limit': 'PictoController.fromCatSubcat',
'GET /sup/:id/pic_fromSearch/:text/category/:id_cat/page/:page/limit/:limit/source/:source': 'PictoController.fromSearch',
'GET /sup/email/:email': 'SupervisorController.getByEmail', 'GET /sup/email/:email': 'SupervisorController.getByEmail',
'GET /sup/changepass/:email': 'SupervisorController.request_change_password', 'GET /sup/changepass/:email': 'SupervisorController.request_change_password',
'PUT /sup/changepass': 'SupervisorController.change_password', 'PUT /sup/changepass': 'SupervisorController.change_password',
......
...@@ -49,6 +49,7 @@ module.exports = function (grunt) { ...@@ -49,6 +49,7 @@ module.exports = function (grunt) {
'assets/scripts/modules/admin/controllers/licenses.js', 'assets/scripts/modules/admin/controllers/licenses.js',
'assets/scripts/modules/admin/controllers/offices.js', 'assets/scripts/modules/admin/controllers/offices.js',
'assets/scripts/modules/admin/controllers/supervisors.js', 'assets/scripts/modules/admin/controllers/supervisors.js',
'assets/scripts/modules/supervisor/controllers/own_pictos.js',
'assets/scripts/modules/supervisor/controllers/supervisor.js', 'assets/scripts/modules/supervisor/controllers/supervisor.js',
'assets/scripts/modules/supervisor/controllers/supervisors.js', 'assets/scripts/modules/supervisor/controllers/supervisors.js',
'assets/scripts/modules/supervisor/controllers/students.js', 'assets/scripts/modules/supervisor/controllers/students.js',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment