Commit 195e6a15 by Arturo Montejo Ráez

Merge branch 'develop'

parents e5557b83 49ac53e1
Showing with 1350 additions and 480 deletions
......@@ -11,6 +11,8 @@ mocha-report.xml
##########
sails/upload
sails/symbolstx*
sails/arasaac*
sails/arasaac
sails/src/assets/symbolstx*
sails/src/assets/upload
sails/upload.tgz
......@@ -35,6 +37,7 @@ sails/logs/
sails/npm-debug.log
sails/playbook.retry
sails/upload.zip
sails/src/config/connections.js-pre
# NOT to be ignored #
# This files override sails-mysql files to support milliseconds timestamps #
......
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
......@@ -11,15 +11,16 @@ android {
versionName "1.0"
resValue "string", "db_name", "PCB.db"
resValue "integer", "db_version", "4"
resValue "string", "app_version", "0.1"
resValue "string", "app_version", "1.1"
resValue "string", "core_vocabulary", "core_vocabulary"
resValue "string", "apk", "to_be_set_in_subproject"
resValue "string", "VersionManagerClass", "to_be_set_in_subproject"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue "string", "server", "https://pictogram.yottacode.com"
resValue "string", "server", "https:/pre.yottacode.com"
resValue "bool", "force_db_create", "false"
resValue "bool", "ssl_connect", "true"
resValue "bool", "force_img_download", "false"
......
......@@ -50,6 +50,8 @@ public class Picto extends Img {
public static String EXPRESSION = "expression";
public static String MIRROR = "mirror";
public static String LEGEND = "legend";
public static String URI_SOUND = "uri_sound";
public static String USER_AVATAR = "user_avatar";
}
......@@ -88,7 +90,7 @@ public class Picto extends Img {
Log.e(LOG_TAG,e.getMessage());
}
}
public Picto(int id, String url, String translation, int cat, int row, int column, int freeRow, int freeColumn, int stupicto_id) throws JSONException {
public Picto(int id, String url, String translation, int cat, int row, int column, int freeRow, int freeColumn, int stupicto_id, String uri_sound, String user_avatar) throws JSONException {
this(id, url, new JSONObject()
.put(JSON_ATTTRS.CATEGORY, cat)
.put(JSON_ATTTRS.COLUMN, column)
......@@ -98,7 +100,10 @@ public class Picto extends Img {
.put(JSON_ATTTRS.STATUS, JSON_ATTTR_STATUS_VALUES.ENABLED)
.put(JSON_ATTTRS.LEGEND,JSON_ATTTR_LEGEND_VALUES.NONE)
.put(JSON_ATTTRS.STUPICTO_ID,stupicto_id)
.put(JSON_ATTTRS.EXPRESSION,translation));
.put(JSON_ATTTRS.EXPRESSION,translation)
.put(JSON_ATTTRS.URI_SOUND,uri_sound)
.put(JSON_ATTTRS.USER_AVATAR,user_avatar)
);
}
public Picto(int id, String url,String translation, String attributes) throws JSONException {
this(id, url, new JSONObject(attributes).put(JSON_ATTTRS.EXPRESSION,translation));
......@@ -246,6 +251,15 @@ public class Picto extends Img {
return false;
}
}
public void set_visible(boolean visible) {
try {
this.attributes.put(JSON_ATTTRS.STATUS, visible ? JSON_ATTTR_STATUS_VALUES.ENABLED : JSON_ATTTR_STATUS_VALUES.INVISIBLE);
} catch (JSONException e) {
Log.e(LOG_TAG,e.getMessage());
}
}
/**
*
* @return the highlight property of a picto
......@@ -277,10 +291,10 @@ public class Picto extends Img {
public String get_legend() {
String legend;
try {
legend=this.attributes.getString(JSON_ATTTRS.LEGEND);
legend=this.attributes.has(JSON_ATTTRS.LEGEND) ? this.attributes.getString(JSON_ATTTRS.LEGEND) : JSON_ATTTR_LEGEND_VALUES.NONE;
} catch (JSONException e) {
legend=JSON_ATTTR_LEGEND_VALUES.NONE; // By default
Log.e(LOG_TAG," Error getting legend:"+e.getMessage());
Log.e(LOG_TAG," Error getting legend:"+e.getMessage()+ "attributes: "+this.attributes.toString());
}
return legend.equalsIgnoreCase("null") ? JSON_ATTTR_LEGEND_VALUES.NONE : legend;
}
......@@ -332,7 +346,21 @@ public class Picto extends Img {
}
}
/**
*
* @return the uri of associated sound of the picto
*/
public String getUriSound(){
return this.attributes.optString(JSON_ATTTRS.URI_SOUND);
}
/**
*
* @return the associated user avatar of the picto
*/
public String getUserAvatar(){
return this.attributes.optString(JSON_ATTTRS.USER_AVATAR);
}
/**
* A picto is a category iif:
......
......@@ -37,6 +37,7 @@ public class User {
static String TTS_ENGINE = "tts engine";
static String TTS_VOICE = "tts voice";
static String DELIVERY = "delivery";
static String SUPERVISORS = "supervisors";
}
public final static class JSON_STUDENT_INPUT_FEEDBACK {
public static String VIBRATION="vibration";
......@@ -49,6 +50,7 @@ public class User {
private JSONObject attributes_stu;
private Img img_sup;
private String email_sup, pwd_sup, name_sup, surname_sup, gender_sup, lang_sup, tts_engine_sup, office_sup;
private String supervisors;
private boolean mirror_mode=false;
......@@ -266,10 +268,16 @@ public class User {
}
}
public String get_Supervisors(){
return this.supervisors;
}
public void set_Supervisors(String newSup){
this.supervisors = newSup;
}
/**
*
* @return input feedback of the student configuration (default: "vibration")
* @return delivery method
*/
public JSON_STUDENT_ATTTRS.delivery delivery() {
JSON_STUDENT_ATTTRS.delivery delivery;
......
......@@ -269,6 +269,7 @@ public class UserLogin {
}
public void login(String username, String password, Activity activity, Class PictogramActivity, Class LoginActivity) {
if (PCBcontext.is_user_logged()) PCBcontext.unset_user();
boolean online= RestapiWrapper.ping(activity.getResources().getString(R.string.server), "server/ping");
if (isSupervisorLoginPattern(username))
manageSupervisorLogin(username,password,online, activity, PictogramActivity, LoginActivity);
......
......@@ -399,7 +399,7 @@ public class Vocabulary implements Iterable<Picto> {
/*
* It saves locally a new picto obtained from the PCB
*/
public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y, final iLocalPicto listener) {
public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y,String uri_sound,String user_avatar, final iLocalPicto listener) {
Picto prev_picto=find_picto(cat, coord_x,coord_y); //¿estamos reemplazanddo un picto que ya existe?
......@@ -411,7 +411,7 @@ public class Vocabulary implements Iterable<Picto> {
int id=PCBcontext.getDevice().getNextLocalPictoID();
try {
final Picto picto = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y, prev_picto!=null ? prev_picto.get_stupicto_id() : Picto.STUPICTO_NULL);
final Picto picto = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y,prev_picto!=null ? prev_picto.get_stupicto_id() : Picto.STUPICTO_NULL,uri_sound,user_avatar);
addPicto(picto, ImgDownloader.tsource.local, new ImgDownloader.iImgDownloaderListener() {
@Override
public void loadComplete() {
......
package com.yottacode.pictogram.net;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.TextView;
import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.R;
......@@ -26,8 +19,6 @@ import java.util.Vector;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static android.app.Activity.RESULT_OK;
/**
* Background services to be executed every "delay" seconds. Tasks to be executed:
......@@ -42,10 +33,10 @@ import static android.app.Activity.RESULT_OK;
public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
static final String LOG_TAG=NetService.class.getCanonicalName();
static final String ping_session="server/ping";
private boolean updated;
private final String LOG_TAG=this.getClass().getCanonicalName();
private Vector<iNetServiceStatus> listeners;
private static final long restfullSynchroTimming=PCBcontext.getContext().getResources().getInteger(R.integer.netservice_force_restfull_synchro)*1000;
private long lastRestfullSynchro;
......@@ -138,16 +129,16 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
public boolean online() {return updated;}
public void restart_app(boolean direct_login) {
public void restart_app(boolean resetPrevLogin) {
for (iNetServiceStatus listener: listeners)
if (listener instanceof iNetServiceDevice) ((iNetServiceDevice)listener).restart_app(direct_login);
PCBcontext.unset_user();
if (listener instanceof iNetServiceDevice) ((iNetServiceDevice)listener).restart_app(resetPrevLogin);
}
/**
* ping to the server by using a restapi call. If ok, the call will return the empty set
*/
Context newVersionContext=null;
@Override
public void run() {
try {
......@@ -160,14 +151,14 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
@Override
public void result(JSONArray result) {
}
@Override
public void result(JSONObject result) {
try {
float version = Float.valueOf(result.getString("version")).floatValue();
if (PCBcontext.getActivityContext() != null && version > DeviceHelper.getAppVersion()) {
Log.e(LOG_TAG, "New version is required! from v" + DeviceHelper.getAppVersion() + " to v" + version);
newVersionAlert(PCBcontext.getActivityContext(), version);
final float version = Float.valueOf(result.getString("version")).floatValue();
if (PCBcontext.getActivityContext() != null && version > DeviceHelper.getAppVersion() && newVersionContext!=PCBcontext.getActivityContext()) {
newVersionContext=PCBcontext.getActivityContext(); // prevent from showing several times the alert
newVersionAlert(version,PCBcontext.getActivityContext(), version);
}
} catch (Exception e) {
Log.e(LOG_TAG, "PING JSON ERROR: " + result + " " + e.getMessage());
......@@ -271,38 +262,18 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
device=(iNetServiceDevice)listener;
return device;
}
static void newVersionAlert(Context contex, final float vnew) {
final SpannableString s = new SpannableString(contex.getResources().getString(R.string.server)
+ "/" + contex.getResources().getString(R.string.apk));
final TextView tx1 = new TextView(contex);
tx1.setText("\t"+contex.getResources().getString(R.string.new_version_detail) +
"\n\t\t"+ s);
tx1.setTextSize(16);
tx1.setAutoLinkMask(RESULT_OK);
tx1.setMovementMethod(LinkMovementMethod.getInstance());
Linkify.addLinks(s, Linkify.WEB_URLS);
AlertDialog.Builder builder = new AlertDialog.Builder(contex);
builder.setTitle(contex.getResources().getString(R.string.app_name)+": "+contex.getResources().getString(R.string.new_version_title)+" v"+vnew)
.setCancelable(false)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
DeviceHelper.setAppVersion(vnew);
}
})
.setView(tx1).setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
static void newVersionAlert(final float version, final Context context, final float vnew) {
try {
iVersionManager versionManager = (iVersionManager)Class.forName(context.getResources().getString(R.string.VersionManagerClass)).newInstance();
versionManager.newVersionAlert(version,context,vnew);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return false;
}
}).show();
PCBcontext.setActivityContext(null);
}
/**
* Created by Fernando on 12/08/2016.
......
......@@ -50,7 +50,7 @@ public class PictoUploader {
bmp=img.get_bitmap(PCBcontext.getContext());
Log.i(LOG_TAG, "Uploading Picto img " + img.file_name() + " from " + img.get_type() + "- Size:" + bmp.getWidth() + " " + bmp.getHeight());
/*Log.i(LOG_TAG, "Uploading Picto img " + img.file_name() + " from " + img.get_type() + "- Size:" + bmp.getWidth() + " " + bmp.getHeight());*/
File file = img.file(PCBcontext.getContext());
......
......@@ -28,8 +28,8 @@ public class ServerLogin {
private static void login(String operation, String email, String username, String password, final RestapiWrapper.iRestapiListener listener){
Hashtable<String, String> postDataParams = new Hashtable<String, String>();
if (email!=null) postDataParams.put("email", email);
if (username!=null) postDataParams.put("username", username);
postDataParams.put("password", password);
if (username!=null) postDataParams.put("username", username);
if (password!=null) postDataParams.put("password", password);
PCBcontext.getRestapiWrapper().ask(operation, postDataParams, "post", new RestapiWrapper.iRestapiListener() {
@Override
public void preExecute() {
......
package com.yottacode.pictogram.net;
import android.content.Context;
/**
* Created by Fernando on 10/03/2017.
*/
public interface iVersionManager {
void newVersionAlert(final float version, final Context context, final float vnew);
}
......@@ -22,22 +22,24 @@ import java.util.Set;
*/
public class TTSHelper {
TextToSpeech ttobj;
TextToSpeech ttobj=null;
Voice voice;
boolean voice_ok;
public void createTTS(final Context context, String engine, final Locale locale, final String voice) {
this.ttobj = new TextToSpeech(context,new TextToSpeech.OnInitListener() {
public void onInit(int status) {
Log.e(this.getClass().getCanonicalName(),"TTS engine "+status);
if (status == TextToSpeech.SUCCESS) {
ttobj.setLanguage(locale);
setVoice(context,voice);
}
}}, engine);
if (this.ttobj==null) {
this.ttobj = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
public void onInit(int status) {
Log.e(this.getClass().getCanonicalName(), "TTS engine " + status);
if (status == TextToSpeech.SUCCESS) {
ttobj.setLanguage(locale);
setVoice(context, voice);
}
}
}, engine);
}
}
public TTSHelper(Context context, String engine, Locale locale,String voice) {
......
......@@ -16,7 +16,7 @@ public class GUITools {
public void ok();
}
public static void show_alert(Context context, int resource_msg, String additional_msg, final iOKListener oklistener) {
public static AlertDialog show_alert(Context context, int resource_msg, String additional_msg, final iOKListener oklistener) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
String msg = context.getString(resource_msg);
if (additional_msg != null) msg += ": " + additional_msg;
......@@ -29,7 +29,9 @@ public class GUITools {
}
});
AlertDialog alert = builder.create();
alert.show();
return alert;
}
public static void show_alert(Context context, int resource_msg) {
......
......@@ -49,9 +49,6 @@
<!--Semantic grammar -->
<string name="loadingGrammar">Please wait, loading vocabulary</string>
<string name="naturalgrammar">SUpO_EN</string>
<string name="pictogrammar">SUpO_PICTOEN</string>
<string name="nogrammar">Warning: unknown language</string>
<!--Upload local img -->
<string name="enterImgLabel">Enter img label</string>
......@@ -68,7 +65,6 @@
<string name="mirror_mode_on">Mirror mode on</string>
<string name="new_version_title">New version available</string>
<string name="new_version_detail">Please, download and install the new version available at</string>
<!--default tts engine and voice-->
<string name="default_tts_engine">com.google.android.tts</string>
......
......@@ -18,6 +18,9 @@
<string name="action_entrar">Entrar</string>
<string name="logout">Cerrar sesión</string>
<string name="loginTitle">¿Quién eres?</string>
<string name="userInetErrorMsg">Este usuario requiere conexión a internet para ser validado</string>
<string name="userLoadingTxt">Cargando</string>
<string name="userLoadingMsg">Cargando alumnos. Por favor espere.</string>
<string name="loginErrorTxt">Login</string>
<string name="loginErrorMsg">El usuario no existe o la contraseña indicada no es correcta. Inténtelo de nuevo.</string>
<string name="loginNoLicenseMsg">La licencia del usuario expiró con fecha. Contacte con Yotta para adquirir una.</string>
......@@ -48,10 +51,6 @@
<!--Semantic grammar -->
<string name="loadingGrammar">Por favor espere, cargando vocabulario</string>
<string name="naturalgrammar">SUpO_ES</string>
<string name="grammar">SUpO_ES</string>
<string name="nogrammar">Advertencia: Lenguaje no soportado</string>
<string name="pictogrammar">SUpO_PICTOES</string>
<!--Upload local img -->
<string name="enterImgLabel">Introduzca etiqueta de la imagen</string>
......@@ -68,7 +67,7 @@
<string name="mirror_mode_on">Modo espejo activado</string>
<string name="new_version_title">Nueva versión disponible</string>
<string name="new_version_detail">Por favor descargue e instale la nueva versión disponible en</string>
<!--default tts engine and voice-->
<string name="default_tts_engine">com.google.android.tts</string>
<string name="default_tts_voice_male">es-es-x-ana#male_1-local</string>
......
......@@ -51,30 +51,15 @@
<!--Semantic grammar -->
<string name="loadingGrammar">Please wait, loading vocabulary</string>
<string name="naturalgrammar">SUpO_EN</string>
<string name="grammar">SUpO_EN</string>
<string name="nogrammar">Warning: unknown language</string>
<string name="pictogrammar">SUpO_PICTOEN</string>
<!--Upload local img -->
<string name="enterImgLabel">Introduzca etiqueta de la imagen</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_ok">Se subió correctamente al servidor</string>
<string name="upload_error">No pudo subirse a Pictogram Web. Se intentará más adelante</string>
<string name="upload_ok">Se subió correctamente a Pictogram Web</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>
<!-- Strings related to login -->
<string name="prompt_email">Email</string>
<string name="prompt_password">Password (optional)</string>
<string name="action_sign_in">Sign in or register</string>
<string name="action_sign_in_short">Sign in</string>
<string name="error_invalid_email">This email address is invalid</string>
<string name="error_invalid_password">This password is too short</string>
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string>
<string name="permission_rationale">"Contacts permissions are needed for providing email completions."</string>
<!--online/offline status-->
<string name="pictogram_offline">Compruebe si tiene conexión a Internet. </string>
<string name="pictogram_online">Conexión con el servidor establecida. </string>
......@@ -85,7 +70,6 @@
<!--new app version alertbox-->
<string name="new_version_title">Nueva versión disponible</string>
<string name="new_version_detail">Por favor descargue e instale la nueva versión disponible en</string>
<!--default tts engine and voice-->
<string name="default_tts_engine">com.google.android.tts</string>
......
#Sun Jan 15 10:11:11 CET 2017
#Mon Mar 06 13:23:58 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
......@@ -18,8 +18,9 @@ android {
targetSdkVersion 22
versionCode 1
versionName "1.0"
resValue "string","SerialClass","com.yottacode.pictogram.supervisor_tablet.gui.Supervisor_SerialActivity"
resValue "string","apk","pictograms.apk"
resValue "bool","NotifyAllwaysVisible","false"
resValue "string", "VersionManagerClass", "com.yottacode.pictogram.supervisor_tablet.net.VersionManager"
resValue "string","apk","pictograms.apk"
// signingConfig signingConfigs.config
}
productFlavors {
......@@ -28,11 +29,11 @@ android {
resValue "bool", "ssl_connect", "false"
}
DevFlavor {
resValue "string", "server", "https://dev.yottacode.com"
resValue "string", "server", "https://dev.pictogramweb.com"
resValue "bool", "ssl_connect", "false"
}
PreFlavor {
resValue "string", "server", "https://pre.yottacode.com"
resValue "string", "server", "https://apk.pictogramweb.com"
resValue "bool", "ssl_connect", "true"
}
LocalFlavor {
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram.supervisor_tablet">
<!-- The app has the permission to receive the RECEIVE_BOOT_COMPLETED broadcast -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- For kiosk mode -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- For the service that restarts the app when another app go to foreground -->
......@@ -20,6 +19,7 @@
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
......@@ -40,7 +40,7 @@
android:label="@string/app_name"
android:screenOrientation="landscape" />
<activity
android:name=".gui.Supervisor_SerialActivity"
android:name="com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity"
android:label="@string/title_activity_serial"
android:screenOrientation="landscape" />
<activity
......
package com.yottacode.pictogram.supervisor_tablet.gui;
import android.app.Activity;
import com.yottacode.pictogram.supervisor_tablet.R;
import com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity;
import com.yottacode.tools.GUITools;
/**
* Created by Fernando on 21/11/2016.
*/
public final class Supervisor_SerialActivity extends SerialActivity {
@Override
protected boolean is_legal_user(String user_name, Activity activity) {
boolean legal_user=com.yottacode.pictogram.dao.UserLogin.isSupervisorLoginPattern(user_name);
if (!legal_user)
GUITools.show_alert(activity, R.string.ilegal_user, user_name);
return legal_user;
}
}
package com.yottacode.pictogram.supervisor_tablet.net;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.view.KeyEvent;
import android.widget.TextView;
import com.yottacode.pictogram.dao.DeviceHelper;
import com.yottacode.pictogram.net.iVersionManager;
import com.yottacode.pictogram.supervisor_tablet.R;
import com.yottacode.pictogram.tools.PCBcontext;
import static android.app.Activity.RESULT_OK;
/**
* Created by Fernando on 10/03/2017.
*/
public class VersionManager implements iVersionManager {
static final String LOG_TAG=VersionManager.class.getCanonicalName();
public void newVersionAlert(final float version, final Context context, final float vnew) {
final SpannableString s = new SpannableString(context.getResources().getString(R.string.server)
+ "/" + context.getResources().getString(com.yottacode.pictogram.R.string.apk));
final TextView tx1 = new TextView(context);
tx1.setText("\t"+context.getResources().getString(R.string.new_version_detail) +
"\n\t\t"+ s);
tx1.setTextSize(16);
tx1.setAutoLinkMask(RESULT_OK);
tx1.setMovementMethod(LinkMovementMethod.getInstance());
Linkify.addLinks(s, Linkify.WEB_URLS);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getResources().getString(R.string.app_name)+": "+context.getResources().getString(R.string.new_version_title)+" v"+vnew)
.setCancelable(false)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
DeviceHelper.setAppVersion(vnew);
}
})
.setView(tx1).setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
return false;
}
}).show();
PCBcontext.setActivityContext(null);
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Pictogram Tablet Supervisor</string>
<string name="ilegal_user">There is not any supervisor named</string>
<string name="new_version_detail">Please, go to Google Play to download the new version </string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Pictogram Tablet Supervisor</string>
<string name="ilegal_user"> No existe ningún supervisor </string>
<string name="new_version_detail">Por favor, descargue la nueva versión en Google Play </string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Pictogram Tablet Supervisor</string>
<string name="ilegal_user">There is not any supervisor named</string>
<string name="new_version_detail">Please, go to Google Play to download the new version </string>
</resources>
......@@ -8,7 +8,7 @@ android {
targetSdkVersion 22
versionCode 1
versionName "1.0"
resValue "string", "SerialClass", "com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity"
resValue "bool","NotifyAllwaysVisible","false"
resValue "integer", "rows", "5"
resValue "integer", "columns", "10"
resValue "integer", "rows_big", "4"
......@@ -31,4 +31,5 @@ dependencies {
compile project(':commonlibrary')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram.tabletlibrary">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<application
android:allowBackup="true"
android:label="@string/app_name"
......
package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import com.yottacode.pictogram.tabletlibrary.R;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.ColorRes;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.ImageView;
public class BotonCircular extends android.support.v7.widget.AppCompatImageView {
private static final int PRESSED_COLOR_LIGHTUP = 255 / 25;
private static final int PRESSED_RING_ALPHA = 75;
private static final int DEFAULT_PRESSED_RING_WIDTH_DIP = 4;
private static final int ANIMATION_TIME_ID = android.R.integer.config_shortAnimTime;
private int centerY;
private int centerX;
private int outerRadius;
private int pressedRingRadius;
private Paint circlePaint;
private Paint focusPaint;
private float animationProgress;
private int pressedRingWidth;
private int defaultColor;
private int pressedColor;
private ObjectAnimator pressedAnimator;
public BotonCircular(Context context) {
super(context);
init(context, null);
}
public BotonCircular(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public BotonCircular(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs);
}
@Override
public void setPressed(boolean pressed) {
super.setPressed(pressed);
if (circlePaint != null) {
circlePaint.setColor(pressed ? pressedColor : defaultColor);
}
if (pressed) {
showPressedRing();
} else {
hidePressedRing();
}
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawCircle(centerX, centerY, pressedRingRadius + animationProgress, focusPaint);
canvas.drawCircle(centerX, centerY, outerRadius - pressedRingWidth, circlePaint);
super.onDraw(canvas);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
centerX = w / 2;
centerY = h / 2;
outerRadius = Math.min(w, h) / 2;
pressedRingRadius = outerRadius - pressedRingWidth - pressedRingWidth / 2;
}
public float getAnimationProgress() {
return animationProgress;
}
public void setAnimationProgress(float animationProgress) {
this.animationProgress = animationProgress;
this.invalidate();
}
public void setColor(int color) {
this.defaultColor = color;
this.pressedColor = getHighlightColor(color,PRESSED_COLOR_LIGHTUP);
circlePaint.setColor(defaultColor);
focusPaint.setColor(pressedColor);
focusPaint.setAlpha(PRESSED_RING_ALPHA);
this.invalidate();
}
/**Esconder anillo exterior animacion*/
private void hidePressedRing() {
pressedAnimator.setFloatValues(pressedRingWidth, 0f);
pressedAnimator.start();
}
public void PhidePressedRing() {
pressedAnimator.setFloatValues(pressedRingWidth, 0f);
pressedAnimator.start();
}
/**Mostrar anillo exterior animacion*/
private void showPressedRing() {
pressedAnimator.setFloatValues(animationProgress, pressedRingWidth);
pressedAnimator.start();
}
public void PshowPressedRing() {
pressedAnimator.setFloatValues(animationProgress, pressedRingWidth);
pressedAnimator.start();
}
private void init(Context context, AttributeSet attrs) {
this.setFocusable(true);
this.setScaleType(ScaleType.CENTER_INSIDE);
setClickable(true);
circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
circlePaint.setStyle(Paint.Style.FILL);
focusPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
focusPaint.setStyle(Paint.Style.STROKE);
pressedRingWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_PRESSED_RING_WIDTH_DIP, getResources()
.getDisplayMetrics());
//int color = Color.rgb(106, 142, 26);
/*if (attrs != null) {
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleButton);
color = a.getColor(R.styleable.CircleButton_cb_color, color);
pressedRingWidth = (int) a.getDimension(R.styleable.CircleButton_cb_pressedRingWidth, pressedRingWidth);
a.recycle();
}*/
int color = getResources().getColor(R.color.VerdeApp);
setColor(color);
focusPaint.setStrokeWidth(pressedRingWidth);
final int pressedAnimationTime = getResources().getInteger(ANIMATION_TIME_ID);
pressedAnimator = ObjectAnimator.ofFloat(this, "animationProgress", 0f, 0f);
pressedAnimator.setDuration(pressedAnimationTime);
}
private int getHighlightColor(int color, int amount) {
return Color.argb(Math.min(255, Color.alpha(color)), Math.min(255, Color.red(color) + amount),
Math.min(255, Color.green(color) + amount), Math.min(255, Color.blue(color) + amount));
}
}
......@@ -16,10 +16,13 @@ import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.PCBcontext;
import java.util.Vector;
import static android.graphics.Color.argb;
/**
......@@ -27,9 +30,10 @@ import static android.graphics.Color.argb;
*/
public class PictoAnimation {
private final String LOG_TAG = this.getClass().getCanonicalName();
public void animateTapeView(final int position, final ViewGroup view) {
private final static String LOG_TAG = PictoAnimation.class.getCanonicalName();
public void animateTapeView(final PictogramActivity activity,final int position, final ViewGroup view) {
final GridView gridview = (GridView) view.getChildAt(1);
final TapeAdapter tapeAdapter=(TapeAdapter)gridview.getAdapter();
......@@ -62,19 +66,21 @@ public class PictoAnimation {
}
@Override
public void onAnimationEnd(Animator animation) { Log.e(LOG_TAG,"animating"+position);
public void onAnimationEnd(Animator animation) {
v.setColorFilter(0);
v.setBackgroundColor(ContextCompat.getColor(PCBcontext.getContext(), R.color.picto_default_background));
if (position < (tapeAdapter.getCount() - 1))
animateTapeView(position + 1, view);
animateTapeView(activity,position + 1, view);
else {
((Activity)view.getContext()).runOnUiThread(new Runnable() {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (tapeAdapter.play())
tapeAdapter.endPlay();
}
});
activity.pictoMainGridAdapter.allPictosInGrid();
activity.pictoCategoryGridAdapter.allPictosInGrid();
}
}
......@@ -116,7 +122,27 @@ public class PictoAnimation {
}
});
moveAnim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (up) activity.ttsButton.setImageAlpha(255);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
moveAnim.setDuration(500);
moveAnim.start();
}
......@@ -166,6 +192,7 @@ public class PictoAnimation {
@Override
public void onAnimationEnd(Animator animation) {
activity.tapeAdapter.deleteItem(position);
activity.tapeAdapter.notifyDataSetChanged();
if (t1.getVisibility()==View.VISIBLE) t1.setAlpha(1);
......@@ -194,4 +221,129 @@ public class PictoAnimation {
colorAnim.start();
}
public static void animateOnGridView(final RelativeLayout layout) {
final PictogramActivity activity=(PictogramActivity)PCBcontext.getActivityContext();
if (activity.inserting) return;
FrameLayout borderlayout=(FrameLayout)layout.getChildAt(0);
final ImageView v=(ImageView)borderlayout.getChildAt(0);
final TextView t1=(TextView)borderlayout.getChildAt(1);
final TextView t2=(TextView)borderlayout.getChildAt(2);
final ValueAnimator colorAnim = ObjectAnimator.ofFloat(0f, 1f) ;
colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float mul = (Float) animation.getAnimatedValue();
if (t2.getVisibility()==View.VISIBLE) {
t2.setAlpha(mul);
v.setImageAlpha(0);
}
else {
v.setImageAlpha((int)(mul*255f));
if (t1.getVisibility() == View.VISIBLE) t1.setAlpha(mul);
}
}
});
colorAnim.addListener(new ValueAnimator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
colorAnim.setDuration(250);
colorAnim.start();
}
public static void animateOutGridView(final PictoGridAdapter pictoGridAdapter, final Picto picto, RelativeLayout layout, final Vector<Picto> pictoLinkedList_inTape) {
final PictogramActivity activity=(PictogramActivity)PCBcontext.getActivityContext();
if (activity.inserting) return;
FrameLayout borderlayout=(FrameLayout)layout.getChildAt(0);
final ImageView v=(ImageView)borderlayout.getChildAt(0);
final TextView t1=(TextView)borderlayout.getChildAt(1);
final TextView t2=(TextView)borderlayout.getChildAt(2);
final int orange = ContextCompat.getColor(PCBcontext.getContext(),R.color.picto_default_background);
final ValueAnimator colorAnim = ObjectAnimator.ofFloat(0f, 1f) ;
colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float mul = (Float) animation.getAnimatedValue();
if (t2.getVisibility()==View.VISIBLE) {
t2.setAlpha(1-mul);
mul=1;
}
int alphaOrange = PictoAnimation.adjustAlpha(orange, mul);
v.setColorFilter(alphaOrange, PorterDuff.Mode.SRC_ATOP);
v.setBackgroundColor(alphaOrange);
v.setPadding(0,0,0,0);
if (mul == 0.0) {
v.setColorFilter(0);
}
if (t1.getVisibility()==View.VISIBLE) t1.setAlpha(1-mul);
}
});
colorAnim.addListener(new ValueAnimator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
if (t2.getVisibility()==View.VISIBLE) v.setBackgroundColor(0);
activity.inserting=true;
}
@Override
public void onAnimationEnd(Animator animation) {
pictoLinkedList_inTape.add(picto);
pictoGridAdapter.notifyDataSetChanged();
if (t1.getVisibility()==View.VISIBLE) t1.setAlpha(1);
if (t2.getVisibility()==View.VISIBLE) t2.setAlpha(1);
v.setColorFilter(0);
v.setBackgroundColor(ContextCompat.getColor(PCBcontext.getContext(), R.color.picto_default_background));
activity.inserting=false;
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
colorAnim.setDuration(200);
colorAnim.start();
}
}
......@@ -3,19 +3,25 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.RelativeLayout;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.PCBcontext;
import java.util.LinkedList;
import java.util.Vector;
public class PictoGridAdapter extends ArrayAdapter {
private LinkedList<Picto> pictoLinkedList;
private final String LOG_TAG = this.getClass().getSimpleName();
private Vector<Picto> pictoLinkedList_inTape;
private Vector<Picto> pictoLinkedList_inGrid;
public PictoGridAdapter(LinkedList<Picto> pictoLinkedList){
super(PCBcontext.getContext(), PictoItemViewGenerator.LAYOUT, pictoLinkedList);
this.pictoLinkedList = pictoLinkedList;
pictoLinkedList_inTape=new Vector<>(5);
pictoLinkedList_inGrid=new Vector<>(5);
}
@Override
......@@ -33,17 +39,54 @@ public class PictoGridAdapter extends ArrayAdapter {
return 0;
}
public void deleteAll() {
this.pictoLinkedList.clear();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return PictoItemViewGenerator.getPictoView(
this.pictoLinkedList.get(position),
convertView,
parent
);
Picto picto=this.pictoLinkedList.get(position);
int igrid=this.pictoLinkedList_inGrid.indexOf(picto);
int itape = this.pictoLinkedList_inTape.indexOf(picto);
if (itape >= 0)
picto.set_visible(false);
if (igrid>=0)
picto.set_visible(true);
View view = PictoItemViewGenerator.getPictoView(
picto,
convertView,
parent
);
if (igrid>=0) {
this.pictoLinkedList_inGrid.remove(igrid);
if (itape>=0) pictoLinkedList_inTape.remove(itape);
PictoAnimation.animateOnGridView((RelativeLayout)view);
}
return view;
}
public void pictoInTape(View view, Picto p) {
PictoAnimation.animateOutGridView(this,p, (RelativeLayout)view, pictoLinkedList_inTape);
}
public void pictoInGrid(Picto p) {
pictoLinkedList_inGrid.add(p);
notifyDataSetChanged();
}
public boolean pictoInThisCategory (Picto picto) {
return pictoLinkedList_inTape.contains(picto);
}
public void allPictosInGrid() {
for (Picto picto: pictoLinkedList_inTape) {
pictoLinkedList_inGrid.add(picto);
}
notifyDataSetChanged();
}
}
package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tabletlibrary.R;
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.tools.GUITools;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -80,7 +87,7 @@ public class PictoMenu {
activity.getIntent().putExtra(Picto.JSON_ATTTRS.EXPRESSION, expression);
//Enviar al PictogramActivity los datos necesarios para crear el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
activity.getIntent().putExtra("cat", cat);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col);
} else {
......@@ -100,6 +107,44 @@ public class PictoMenu {
}
public void setPicto(int row, int col, int cat, String expression, Bitmap bitmap, int id_picto, String uri_sound, String user_avatar){
Intent intent = new Intent(activity, EditPictoActivity.class);
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, expression);
intent.putExtra(Picto.JSON_ATTTRS.STUPICTO_ID,id_picto);
intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,uri_sound);
//Enviar al PictogramActivity los datos necesarios para editar el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
intent.putExtra(Picto.JSON_ATTTRS.ROW, row);
intent.putExtra(Picto.JSON_ATTTRS.COLUMN, col);
} else {
intent.putExtra(Picto.JSON_ATTTRS.FREE_ROW, row);
intent.putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col);
}
if(bitmap!=null) {
Point size= GUITools.getScreenSize(activity);
float bWidth = bitmap.getWidth();
float bHeight = bitmap.getHeight();
float factorX=size.x*0.7f/bWidth;
float factorY=size.y*0.7f/bHeight;
float factor= factorY>factorX ? factorX : factorY;
bWidth=bWidth*factor;
bHeight=bHeight*factor;
Bitmap rescaled = Bitmap.createScaledBitmap(bitmap,(int) bWidth, (int) bHeight, true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra(EditPictoActivity.IMAGE_PICTO, byteArray);
}
intent.putExtra("tipo",true);
activity.startActivityForResult(intent,EditPictoActivity.EDIT_PICTO_REQUEST);
}
/**Function for build a radial menu
*
* @param is_picto_big
......@@ -245,21 +290,29 @@ public class PictoMenu {
}
public String getName() { return "edit"; }
public String getLabel() { return null; }
public int getIcon() { return R.drawable.edit_picture; }
public int getIcon() { return R.drawable.edit; }
private List<RadialMenuWidget.RadialMenuEntry> children;
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return children; }
public void menuActiviated()
{
ll.getChildAt(1).setX(ll.getChildAt(1).getX() + 30);
children = new ArrayList<>(Arrays.asList(new PickFromCamera(p),new PickFromGallery(p)));
ll.setVisibility(View.GONE);
ll.removeAllViewsInLayout();
try {
setPicto(p.get_row(),p.get_column(),p.get_category(),p.get_translation(),p.get_bitmap(PCBcontext.getContext()),p.get_stupicto_id(),p.getUriSound(),p.getUserAvatar());
} catch (IOException e) {
e.printStackTrace();
}
//ll.getChildAt(1).setX(ll.getChildAt(1).getX() + 30);
//children = new ArrayList<>(Arrays.asList(new PickFromCamera(p),new PickFromGallery(p)));
}
public void menuDisabled(){
ll.getChildAt(1).setX(ll.getChildAt(1).getX() - 30);
//ll.getChildAt(1).setX(ll.getChildAt(1).getX() - 30);
}
}
public class PickFromCamera implements RadialMenuWidget.RadialMenuEntry
/*public class PickFromCamera implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public PickFromCamera(Picto picto){
......@@ -296,7 +349,7 @@ public class PictoMenu {
addPicto(p.get_row(),p.get_column(),p.get_category(),p.get_translation(),1);
}
public void menuDisabled(){}
}
}*/
public class newPickFromCamera implements RadialMenuWidget.RadialMenuEntry
{
......
......@@ -18,6 +18,7 @@ import java.util.LinkedList;
public class TapeAdapter extends BaseAdapter {
private static final String LOG_TAG = TapeAdapter.class.getName();
//private Context mContext;
private LinkedList<Picto> pictoLinkedList;
private boolean play = false;
......@@ -45,24 +46,31 @@ public class TapeAdapter extends BaseAdapter {
}
// AÑADIR ITEM AL ADAPTADOR
public void addItem(Picto p) {
pictoLinkedList.add(p);
public int addItem(Picto p) {
pictoLinkedList.add(new Picto(p));
return pictoLinkedList.size()-1;
}
// ELIMINAR ITEM DEL ADAPTADOR
public void deleteItem(int position) {
pictoLinkedList.remove(position);
try {
pictoLinkedList.remove(position);
}catch(IndexOutOfBoundsException e) {
Log.e(LOG_TAG,"Error deleting item from tape adapter:"+e.getMessage());
}
}
// ELIMINAR el último ITEM DEL ADAPTADOR
public void deleteLastView() {
public Picto deleteLastView() {
Picto picto=null;
// Controlar excepcion al intentar eliminar el último cuando no hay elementos
try {
pictoLinkedList.removeLast();
picto=pictoLinkedList.removeLast();
} catch (ArrayIndexOutOfBoundsException exception) {
Log.e("Excepción", "ArrayIndexOutOfBounds: " + exception.getMessage());
}
return picto;
}
// ELIMINAR TODOS LOS ITEMS DEL ADAPTADOR
......@@ -74,7 +82,6 @@ public class TapeAdapter extends BaseAdapter {
public void clear() {
pictoLinkedList.clear();
notifyDataSetChanged();
}
// DEVUELVE TODOS LOS ELEMENTOS
public LinkedList<Picto> getAll() {
......
......@@ -31,7 +31,7 @@ import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.Paint
*
* Class to see it on the image to crop
*/
public class CropImageView extends ImageView {
public class CropImageView extends android.support.v7.widget.AppCompatImageView {
......
......@@ -22,7 +22,7 @@ public class PaintUtil {
final Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(resources.getDimension(R.dimen.border_thickness));
paint.setColor(resources.getColor(R.color.border));
paint.setColor(resources.getColor(R.color.VerdeApp));
return paint;
}
......@@ -35,7 +35,7 @@ public class PaintUtil {
final Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(resources.getDimension(R.dimen.guideline_thickness));
paint.setColor(resources.getColor(R.color.guideline));
paint.setColor(resources.getColor(R.color.VerdeApp));
return paint;
}
......@@ -62,7 +62,7 @@ public class PaintUtil {
final Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(resources.getDimension(R.dimen.corner_thickness));
paint.setColor(resources.getColor(R.color.corner));
paint.setColor(resources.getColor(R.color.VerdeApp));
return paint;
}
......
......@@ -2,6 +2,10 @@ package com.yottacode.pictogram.tabletlibrary.gui.login;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.provider.ContactsContract;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -10,6 +14,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.PCBcontext;
import java.util.Vector;
......@@ -19,6 +24,7 @@ import java.util.Vector;
*/
public class CustomList extends ArrayAdapter<String>{
private boolean color;
private final Activity context;
private final String[] name_surname;
private final Vector<Bitmap> images;
......@@ -34,6 +40,7 @@ public class CustomList extends ArrayAdapter<String>{
this.context = context;
this.name_surname = name_surname;
this.images = images;
this.color = true;
}
/**
......@@ -51,9 +58,27 @@ public class CustomList extends ArrayAdapter<String>{
ImageView imageView = (ImageView) rowView.findViewById(R.id.loginStudentPhoto);
txtTitle.setText(name_surname[position]);
ImageView fondo = (ImageView) rowView.findViewById(R.id.fondo);
//if(color){
// color = false;
// rowView.setBackgroundColor(ContextCompat.getColor(context, R.color.VerdeApp));
// txtTitle.setTextColor(ContextCompat.getColor(context, R.color.BlancoApp));
// fondo.setBackgroundResource(R.drawable.round_design_photo_green);
//}else{
// color = true;
rowView.setBackgroundColor(ContextCompat.getColor(context, R.color.BlancoApp));
txtTitle.setTextColor(ContextCompat.getColor(context, R.color.VerdeApp));
fondo.setBackgroundResource(R.drawable.round_design_photo_white);
//}
//imageView.setImageResource(R.drawable.user);
if (images.size()>0) imageView.setImageBitmap(images.elementAt(position));
else imageView.setImageResource(R.drawable.anonymous_student);
if (images.size()>0){
imageView.setImageBitmap(images.elementAt(position));
}else{
imageView.setImageResource(R.drawable.anonymous_student);
}
return rowView;
}
}
......@@ -42,8 +42,10 @@ public class CustomListLogin extends ArrayAdapter<User>{
ImageView imageView = (ImageView) rowView.findViewById(R.id.photo);
ImageView fondo = (ImageView) rowView.findViewById(R.id.fondoFotoLogin);
try {
Bitmap photo=getItem(position).is_supervisor() ? getItem(position).get_bitmap_sup(getContext()) : getItem(position).get_bitmap_stu(getContext());
fondo.setImageResource(R.drawable.round_design_photo_white);
if (photo!=null) imageView.setImageBitmap(photo);
else imageView.setImageResource(R.drawable.anonymous_student);
} catch (IOException e) {
......
......@@ -40,7 +40,6 @@ public class LoginActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(com.yottacode.pictogram.tabletlibrary.R.layout.activity_login);
......@@ -51,14 +50,7 @@ public class LoginActivity extends FragmentActivity {
logoutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Class serialClass;
try {
serialClass=Class.forName(getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(this.getClass().getCanonicalName(),"S:"+getString(R.string.SerialClass));
serialClass=SerialActivity.class;
}
Intent serialActivity = new Intent(getBaseContext(), serialClass);
Intent serialActivity = new Intent(getBaseContext(), com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", true);
startActivity(serialActivity);
}
......
......@@ -25,14 +25,7 @@ public class MainActivity extends Activity {
// For deactivating the lock screen (just before setContentView)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
Class serialClass;
try {
serialClass=Class.forName(getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(this.getClass().getCanonicalName(),"S:"+getString(R.string.SerialClass));
serialClass=SerialActivity.class;
}
Intent serialActivity = new Intent(this, serialClass);
Intent serialActivity = new Intent(this, com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", false);
startActivity(serialActivity);
}
......
......@@ -43,8 +43,6 @@ public class SerialActivity extends Activity {
LinearLayout stuList;
LinearLayout supList;
protected boolean is_legal_user(String user_name, Activity activity) {return true;}
/**
* Return the default user+pwd when login.The policy is
* 1. switch user
......@@ -155,24 +153,25 @@ public class SerialActivity extends Activity {
@Override
public void onClick(View view) {
String username = mSerialViewMail.getText().toString();
if (is_legal_user(username,SerialActivity.this)) {
String password = mSerialViewPass.getText().toString();
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("username", username);
editor.putString("password", password);
editor.commit();
if (!username.equals("") && !password.equals(""))
String password = mSerialViewPass.getText().toString();
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("username", username);
editor.putString("password", password);
editor.commit();
if (!username.equals("") && !password.equals(""))
new UserLogin().login(username, password, SerialActivity.this, PictogramActivity.class, LoginActivity.class);
}
}
});
}
@Override
public void onStart() {
Vector<User> users;
Log.i(this.getClass().getCanonicalName(),"Starting serial activity (direct login:"+!getIntent().getBooleanExtra("resetPrevUser", true)+")");
Log.i(this.getClass().getCanonicalName(),"Starting serial activity (Reset Prev user:"+getIntent().getBooleanExtra("resetPrevUser", true)+")");
if (!PCBcontext.init()) PCBcontext.init(this, new NetServiceTablet());
String default_user[] = loginUserPolicy();
String username = default_user[0];
......@@ -182,7 +181,6 @@ public class SerialActivity extends Activity {
mSerialViewMail.setText(username);
mSerialViewPass.setText(password);
if (!username.equals("") && !password.equals("") && !getIntent().getBooleanExtra("resetPrevUser", true))
new UserLogin().login(username, password, SerialActivity.this, PictogramActivity.class, LoginActivity.class);
......@@ -197,5 +195,10 @@ public class SerialActivity extends Activity {
}
}
@Override
public void onResume() {
super.onResume();
PCBcontext.setActivityContext(this);
}
}
......@@ -18,6 +18,7 @@ import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity;
import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
......@@ -27,6 +28,8 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
/**
......@@ -80,8 +83,10 @@ public class StudentFragmentGrid extends Fragment{
PCBcontext.set_user(currentUser, null, null);
Intent pictogramActivity = new Intent(getActivity(), PictogramActivity.class);
startActivity(pictogramActivity);
} else
} else {
new_user(i);
download_supervisors(PCBcontext.getPcbdb().getCurrentUser().get_id_stu());
}
}
private void new_user(int i) {
......@@ -198,6 +203,47 @@ public class StudentFragmentGrid extends Fragment{
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs);
}
private void download_supervisors(int stu_id) {
String token = getActivity().getIntent().getExtras().getString("token");
RestapiWrapper wrapper = PCBcontext.getRestapiWrapper();
wrapper.setToken(token);
String operation = "stu/" + stu_id + "/supervisors";
wrapper.ask(operation, new RestapiWrapper.iRestapiListener() {
@Override
public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage());
GUITools.show_alert(getActivity(), R.string.loginErrorTxt, getString(R.string.serverError), new GUITools.iOKListener() {
@Override
public void ok() {
PCBcontext.getNetService().restart_app(false);
}
});
}
@Override
public void preExecute() {
}
@Override
public void result(JSONArray supervisors) {
String supervisorsFormat = "";
for (int i=0;i<supervisors.length();i++) {
JSONObject supervisor;
try {
supervisor = supervisors.getJSONObject(i);
supervisorsFormat += supervisor.get("name") +" " + supervisor.get("surname") + "," + supervisor.get("email") + ";";
} catch (JSONException e) {
e.printStackTrace();
}
}
PCBcontext.getPcbdb().getCurrentUser().set_Supervisors(supervisorsFormat);
}
@Override
public void result(JSONObject result) {
}
});
}
private void download_students(int sup_id ) {
String token = getActivity().getIntent().getExtras().getString("token");
......
......@@ -13,7 +13,6 @@ import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.NetService;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity;
import com.yottacode.pictogram.tools.PCBcontext;
/**
......@@ -31,36 +30,40 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
public void build() {
this.builder = new NotificationCompat.Builder(PCBcontext.getContext()).setAutoCancel(true).setOngoing(true);
this.builder = new NotificationCompat.Builder(PCBcontext.getContext()).setAutoCancel(true).setOngoing(PCBcontext.getContext().getResources().getBoolean(R.bool.NotifyAllwaysVisible));
Intent resultIntent = new Intent(PCBcontext.getContext(), PictogramActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(PCBcontext.getContext());
stackBuilder.addParentStack(PictogramActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
if (PCBcontext.getContext().getResources().getBoolean(R.bool.NotifyAllwaysVisible)){
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
}
}
public void notifyStatus(boolean updated) {
String user="";
if (PCBcontext.getPcbdb()!=null) {
if (PCBcontext.getPcbdb()!=null ) {
user=PCBcontext.getPcbdb().getCurrentUser().get_name_stu()+" "+PCBcontext.getPcbdb().getCurrentUser().get_surname_stu();
if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor())
user += " (" + PCBcontext.getPcbdb().getCurrentUser().get_name_sup() + ")";
}
if (updated)
builder.setSmallIcon(R.drawable.application_online)
if (PCBcontext.getActivityContext()!=null) {
if (updated)
builder.setSmallIcon(R.drawable.application_online)
.setContentTitle(PCBcontext.getContext().getResources().getString(R.string.pictogram_online))
.setContentText(user);
else
builder.setSmallIcon(R.drawable.application_offline)
else
builder.setSmallIcon(R.drawable.application_offline)
.setContentTitle(PCBcontext.getContext().getResources().getString(R.string.pictogram_offline))
.setContentText(user);
NotificationManager mNotificationManager =
NotificationManager mNotificationManager =
(NotificationManager) PCBcontext.getContext().getSystemService(PCBcontext.getContext().NOTIFICATION_SERVICE);
mNotificationManager.notify(notifyID, builder.build());
mNotificationManager.notify(notifyID, builder.build());
}
}
public void closeNotifyStatus(){
NotificationManager mNotificationManager =
......@@ -75,34 +78,21 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
Log.i(LOG_TAG,"App restarting");
Context context=activity.getBaseContext();
Class serialClass;
try {
serialClass=Class.forName(context.getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(LOG_TAG,"S:"+PCBcontext.getContext().getString(R.string.SerialClass));
serialClass=SerialActivity.class;
}
Intent serialActivity = new Intent(context, serialClass);
Intent serialActivity = new Intent(context, com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", false);
serialActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(serialActivity);
activity.finish();
}
public void restart_app(boolean direct_login) {
public void restart_app(boolean resetPrevUser) {
Log.i(LOG_TAG,"App restarting");
Log.e(LOG_TAG,"App restarting, reset last login:"+resetPrevUser);
Context context=PCBcontext.getContext();
Context context=PCBcontext.getActivityContext();
Class serialClass;
try {
serialClass=Class.forName(PCBcontext.getContext().getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(LOG_TAG,"S:"+PCBcontext.getContext().getString(R.string.SerialClass));
serialClass=SerialActivity.class;
}
Intent serialActivity = new Intent(context, serialClass);
serialActivity.putExtra("resetPrevUser", direct_login);
Intent serialActivity = new Intent(context, com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", resetPrevUser);
context.startActivity(serialActivity);
}
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- main color -->
<item
android:bottom="2dp"
android:left="2dp"
android:right="2dp">
<shape>
<solid android:color="@color/BlancoApp" />
</shape>
</item>
<item>
<selector >
<item android:state_enabled="true"
android:state_focused="true">
<shape>
<stroke
android:width="2dp"
android:color="@color/VerdeApp"/>
</shape>
</item>
<item android:state_enabled="true">
<shape>
<stroke
android:width="2dp"
android:color="@color/gray"/>
</shape>
</item>
</selector>
</item>
<!-- draw another block to cut-off the left and right bars -->
<item android:bottom="5.0dp">
<shape>
<solid android:color="@color/BlancoApp" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- main color -->
<item
android:bottom="2dp"
android:left="2dp"
android:right="2dp">
<shape>
<solid android:color="#FFFFFF" />
</shape>
</item>
<item>
<selector >
<item android:state_enabled="true"
android:state_focused="true">
<shape>
<stroke
android:width="2dp"
android:color="@color/VerdeApp"/>
</shape>
</item>
<item android:state_enabled="true">
<shape>
<stroke
android:width="2dp"
android:color="#ffffffff"/>
</shape>
</item>
</selector>
</item>
<!-- draw another block to cut-off the left and right bars -->
<item android:bottom="5.0dp">
<shape>
<solid android:color="#ffffff" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#AfD260"/>
<stroke android:width="3dip" android:color="#EEEEEE" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#EEEEEE"/>
<stroke android:width="3dip" android:color="#AFD260" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
......@@ -6,62 +6,64 @@
tools:context="com.yottacode.pictogram.tabletlibrary.gui.login.LoginActivity">
<RelativeLayout
android:id="@+id/loginTopbarLayout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="8dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="0dp"
android:id="@+id/loginTopbarLayout">
android:layout_height="70dp"
android:background="@color/VerdeApp"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:id="@+id/loginTopbarSupervisorPhoto"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="left"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:background="@color/accent_material_dark"
android:scaleType="centerCrop" />
android:scaleType="centerCrop"
android:layout_centerVertical="true"
android:layout_alignParentStart="true" />
<LinearLayout
android:orientation="vertical"
android:id="@+id/loginTopbarSupervisorNameLayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/loginTopbarSupervisorNameLayout"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/loginTopbarSupervisorPhoto"
android:gravity="center_vertical">
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/loginTopbarSupervisorFullName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="@+id/loginTopbarSupervisorFullName" />
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/BlancoApp" />
<TextView
android:id="@+id/loginTopbarSupervisorUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="@+id/loginTopbarSupervisorUserName"
android:textColor="@color/abc_secondary_text_material_light" />
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/BlancoApp" />
</LinearLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:id="@+id/loginTopbarLogout"
style="@android:style/TextAppearance.Material.Button"
android:textColor="@color/BlancoApp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/logout"
android:id="@+id/loginTopbarLogout"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:enabled="false" />
android:enabled="false"
android:text="@string/logout" />
</RelativeLayout>
......@@ -77,27 +79,18 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/loginTopbarLayout">
android:layout_below="@+id/loginTopbarLayout"
android:paddingTop="10dp">
<fragment
android:id="@+id/loginStudentGrid"
class="com.yottacode.pictogram.tabletlibrary.gui.login.StudentFragmentGrid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
class="com.yottacode.pictogram.tabletlibrary.gui.login.StudentFragmentGrid"
android:id="@+id/loginStudentGrid"
android:layout_gravity="center"
android:layout_gravity="top"
tools:layout="@layout/fragment_new_student" />
</FrameLayout>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/imageView4"
android:background="@drawable/pictogram_logo"
android:layout_marginRight="30dp"
android:layout_below="@+id/view"
android:layout_alignEnd="@+id/loginTopbarLayout"
android:layout_marginTop="320dp" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
......
......@@ -14,6 +14,7 @@
android:layout_marginTop="8dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="0dp"
android:background="@color/VerdeApp"
android:id="@+id/sessionTopbarLayout">
<ImageView
......
......@@ -33,7 +33,7 @@
android:layout_height="wrap_content"
android:textStyle="normal|bold"
android:textAlignment="center"
android:background="@color/common_google_signin_btn_text_light_disabled" />
android:background="@color/VerdeApp" />
<ListView
android:id="@+id/methodsListView"
......@@ -55,10 +55,10 @@
<TextView
android:text="@string/session_instruction"
android:background="@color/VerdeApp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="normal|bold"
android:background="@color/common_google_signin_btn_text_light_disabled"
android:textAlignment="center" />
<ListView
......
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loginStudentGridView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:gravity="center_vertical|center|center_horizontal"
android:stackFromBottom="false"
android:padding="32dp"
android:horizontalSpacing="16dp"
android:verticalSpacing="16dp" />
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loginStudentGridView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numColumns="5"
android:stackFromBottom="false" />
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal">
<ImageView
android:id="@+id/loginStudentPhoto"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="50dp"
android:layout_marginTop="50dp"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageView
android:id="@+id/fondo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignBottom="@+id/loginStudentName"
android:layout_centerHorizontal="false"
android:layout_gravity="center"
android:background="@drawable/round_design_photo_green" />
<ImageView
android:id="@+id/loginStudentPhoto"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignWithParentIfMissing="true"
android:layout_centerHorizontal="false"
android:layout_centerVertical="true"
android:layout_gravity="center" />
</FrameLayout>
<TextView
android:id="@+id/loginStudentName"
android:layout_width="128dp"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_below="@+id/loginStudentPhoto"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_centerHorizontal="true"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:gravity="center" />
</RelativeLayout>
\ No newline at end of file
android:layout_gravity="center"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:text="Nombre"
android:layout_height="wrap_content"
android:id="@+id/label_name"
android:layout_weight="0.15"
android:textSize="18sp"
android:textColor="@android:color/black"
android:layout_alignTop="@+id/photo"
android:layout_toEndOf="@+id/photo"
android:layout_width="wrap_content"
android:layout_marginStart="15dp" />
<TextView
android:text="Apellidos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_surname"
android:textSize="18sp"
android:textAlignment="textStart"
android:textColor="@android:color/black"
android:layout_alignBottom="@+id/photo"
android:layout_toEndOf="@+id/photo"
android:layout_marginStart="15dp" />
<ImageView
app:srcCompat="@drawable/anonymous_student"
android:id="@+id/photo"
android:layout_weight="0.15"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@color/BlancoApp"
android:orientation="vertical">
<LinearLayout
android:layout_width="276dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<FrameLayout
android:layout_width="50dp"
android:layout_height="50dp">
<ImageView
android:id="@+id/fondoFotoLogin"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
app:srcCompat="@drawable/round_design_photo_white" />
<ImageView
android:id="@+id/photo"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_weight="1"
app:srcCompat="@drawable/anonymous_student" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/label_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/photo"
android:layout_marginStart="15dp"
android:layout_toEndOf="@+id/photo"
android:layout_weight="0.15"
android:text="Nombre"
android:textColor="@color/VerdeApp"
android:textSize="18sp" />
<TextView
android:id="@+id/label_surname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/photo"
android:layout_marginStart="15dp"
android:layout_toEndOf="@+id/photo"
android:layout_weight="0.15"
android:text="Apellidos"
android:textAlignment="textStart"
android:textColor="@color/VerdeApp"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<resources>
<string name="app_name">com.yottacode.pictogram.Tablet</string>
<string name="alumnos">Students</string>
<string name="supervisores">Supervisors</string>
<item name="maxInTape" type="integer">8</item>
<item name="maxInTape_big" type="integer">6</item>
......@@ -35,14 +37,15 @@
<string name="session_eval_notevuated">not evaluated</string>
<string name="session_eval_discarded">discarded</string>
<string name="crop">Crop</string>
<string name="titleCropper">Edit Picto</string>
<string name="croppedImageDesc">Preview</string>
<string name="cancel">Cancel</string>
<string name="accept">Accept</string>
<string name="legendText">Legend</string>
<string name="dialogCamera">Take a Picture</string>
<string name="dialogGallery">Pick from Gallery</string>
<string name="dialogTitle">Choose Method</string>
<string name="dialogCancel">Cancel</string>
<!-- Cropper -->
<string name="crop_TextRequired">Por favor, introduzca una leyenda para el pictograma</string>
<string name="uploadingImage">Subiendo imagen al servidor</string>
<string name="titleCropperEdit">Edit Picto</string>
<string name="titleCropperNew">New Picto</string>
</resources>
<resources>
<string name="app_name">com.yottacode.pictogram.Tablet</string>
<string name="alumnos">Estrudiantes</string>
<string name="supervisores">Supervisores</string>
<item name="maxInTape" type="integer">8</item>
<item name="maxInTape_big" type="integer">6</item>
......@@ -9,7 +11,7 @@
<string name="session_header">Seleccion de método e instrucció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_loading">Desargando instrucciones</string>
<string name="session_loading">Descargando instrucciones</string>
<string name="session_empty">Este alumno no tiene ningún método asignado. Por favor asigne un método a este alumno en</string>
<string name="session_notclosed">Este alumno tiene una sesión abierta. Por favor cierre la sesión desde Pictogram Web en</string>
<string name="session_closed_ok">Sesión grabada correctamente. Hora</string>
......@@ -35,12 +37,14 @@
<string name="session_eval_notevuated">no evaluado</string>
<string name="session_eval_discarded">inválido</string>
<string name="crop">Recortar</string>
<string name="titleCropper">Nuevo Pictograma</string>
<string name="crop_TextRequired">Por favor, introduzca una leyenda para el pictograma</string>
<!-- Cropper -->
<string name="legendText">Leyenda:</string>
<string name="dialogCamera">Hacer Foto</string>
<string name="dialogGallery">Seleccionar de Galería</string>
<string name="dialogTitle">Seleccionar Método</string>
<string name="dialogCancel">Cancelar</string>
<string name="uploadingImage">Subiendo imagen al servidor</string>
<string name="cancel">Cancelar</string>
<string name="titleCropperEdit">Editar Pictograma</string>
<string name="titleCropperNew">Nuevo Pictograma</string>
</resources>
......@@ -6,7 +6,7 @@
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="gray_blue">#FF78909C</color>
<color name="blue_light">#FF40C4FF</color>
<color name="blue_light">#40c4ff</color>
<color name="gray">#FF727272</color>
......@@ -14,5 +14,7 @@
<color name="guideline">@color/white_translucent</color>
<color name="corner">@android:color/white</color>
<color name="surrounding_area">@color/black_translucent</color>
<color name="VerdeApp">#6a8e1a</color>
<color name="BlancoApp">#eeeeee</color>
</resources>
......@@ -11,7 +11,7 @@
<string name="session_header">Select method and instruction</string>
<string name="session_error">Server Error </string>
<string name="session_noinstructions">Student without any instrucction assigment</string>
<string name="session_loading">Desargando instrucciones</string>
<string name="session_loading">Descargando instrucciones</string>
<string name="session_empty">Este alumno no tiene ningún método asignado. Por favor asigne un método a este alumno en</string>
<string name="session_notclosed">Este alumno tiene una sesión abierta. Por favor cierre la sesión en el panel de control de Pictogram Web</string>
<string name="session_closed_ok">Sesión grabada correctamente</string>
......@@ -38,27 +38,13 @@
<string name="session_eval_discarded">inválido</string>
<!-- Dialog for add new picto -->
<string name="dialogTitle">Seleccionar método</string>
<string name="dialogCamera">Hacer Foto</string>
<string name="dialogGallery">Seleccionar de Galería</string>
<string name="dialogCancel">Cancelar</string>
<!-- Cropper -->
<string name="legendText">Leyenda:</string>
<string name="fixedAspectRatio">fixedAspectRatio =\u0020</string>
<string name="aspectRatioXHeader">aspectRatioX =\u0020</string>
<string name="aspectRatioYHeader">aspectRatioY =\u0020</string>
<string name="showGuidelines">showGuidelines =\u0020</string>
<string name="crop">Recortar</string>
<string name="titleCropper">Nuevo Pictograma</string>
<string name="titleCropperNew">Nuevo Pictograma</string>
<string name="titleCropperEdit">Editar Pictograma</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">
<item>Off</item>
<item>On Touch</item>
<item>On</item>
</string-array>
<string name="cancel">Cancel</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources xmlns:android="http://schemas.android.com/tools">
<style name="sessionBtn">
<item name="android:layout_height">64dp</item>
<item name="android:layout_width">64dp</item>
......
......@@ -18,8 +18,9 @@ android {
targetSdkVersion 22
versionCode 1
versionName "1.0"
resValue "string","SerialClass","com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity"
resValue "bool","NotifyAllwaysVisible","true"
resValue "string","apk","pictogram.apk"
resValue "string", "VersionManagerClass", "com.yottacode.pictogram.yotta_tablet.net.com.yottacode.pictogram.yotta_tablet.net.VersionManager"
// signingConfig signingConfigs.config
}
productFlavors {
......@@ -28,12 +29,14 @@ android {
resValue "bool", "ssl_connect", "false"
}
DevFlavor {
resValue "string", "server", "https://dev.yottacode.com"
resValue "string", "server", "https://dev.pictogramweb.com"
resValue "bool", "ssl_connect", "false"
resValue "string","apk","pictogram_dev.apk"
}
PreFlavor {
resValue "string", "server", "https://pre.yottacode.com"
resValue "string", "server", "https://apk.pictogramweb.com"
resValue "bool", "ssl_connect", "true"
resValue "string","apk","pictogram.apk"
}
LocalFlavor {
resValue "string", "server", "http://192.168.1.35:1337"
......
package com.yottacode.pictogram.yotta_tablet.kiosk;
import android.app.ActivityManager;
import android.app.NotificationManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
......@@ -39,6 +40,9 @@ public class KioskService extends Service {
public void onDestroy() {
Log.i(TAG, "Stopping service 'KioskService'");
running =false;
NotificationManager mNotificationManager =
(NotificationManager)this.getBaseContext().getSystemService(this.getBaseContext().NOTIFICATION_SERVICE);
mNotificationManager.cancel(666);
super.onDestroy();
}
......
package com.yottacode.pictogram.yotta_tablet.net.com.yottacode.pictogram.yotta_tablet.net;
import android.app.DownloadManager;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Environment;
import com.yottacode.pictogram.dao.DeviceHelper;
import com.yottacode.pictogram.net.iVersionManager;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.yotta_tablet.R;
import com.yottacode.tools.GUITools;
import java.io.File;
/**
* Created by Fernando on 10/03/2017.
*/
public class VersionManager implements iVersionManager {
static final String LOG_TAG=VersionManager.class.getCanonicalName();
public void newVersionAlert(final float version, final Context context, final float vnew) {
GUITools.show_alert(
PCBcontext.getActivityContext(), R.string.new_version_title,
PCBcontext.getContext().getResources().getString(R.string.new_version_detail)+" v" + version, new GUITools.iOKListener() {
@Override
public void ok() {
downloadNewVersion(version,PCBcontext.getActivityContext(), version);
}
});
}
private void downloadNewVersion(final float version, final Context context, final float vnew) {
final ProgressDialog progressDialog=ProgressDialog.show(context, context.getString(R.string.userLoadingTxt),context.getString(R.string.new_version_downloading));
progressDialog.show();
String destination = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/";
String fileName = context.getResources().getString(com.yottacode.pictogram.R.string.apk);
String apkurl=context.getResources().getString(com.yottacode.pictogram.R.string.server)
+ "/" + fileName;
destination += fileName;
final Uri uri = Uri.parse("file://" + destination);
//Delete update file if exists
File file = new File(destination);
if (file.exists())
file.delete();
//set downloadmanager
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(apkurl));
request.setDescription(context.getString(R.string.new_version_detail));
request.setTitle(context.getString(com.yottacode.pictogram.R.string.app_name));
//set destination
request.setDestinationUri(uri);
// get download service and enqueue file
final DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
final long downloadId = manager.enqueue(request);
//register receiver for when .apk download is compete
context.registerReceiver(new BroadcastReceiver() {
public void onReceive(Context ctxt, Intent intent) {
progressDialog.dismiss();
Intent install = new Intent(Intent.ACTION_VIEW);
install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
install.setDataAndType(uri,
manager.getMimeTypeForDownloadedFile(downloadId));
context.startActivity(install);
context.unregisterReceiver(this);
DeviceHelper.setAppVersion(version);
}
}
, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}
}
......@@ -2,5 +2,8 @@
<resources>
<string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user">There is not any supervisor named</string>
<string name="new_version_detail">Pulse OK para proceder con la instalación</string>
<string name="new_version_downloading">Please wait, downloading new version </string>
</resources>
......@@ -2,5 +2,8 @@
<resources>
<string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user"> No existe ningún supervisor </string>
<string name="new_version_detail">Pulse OK para proceder con la instalación</string>
<string name="new_version_downloading">Por favor espere, descargando nueva versión </string>
</resources>
......@@ -2,4 +2,7 @@
<resources>
<string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user">There is not any supervisor named</string>
<string name="new_version_detail">Pulse OK para proceder con la instalación</string>
<string name="new_version_downloading">Por favor espere, descargando nueva versión </string>
</resources>
......@@ -21,7 +21,7 @@ mostradas más adelante hacen todo el trabajo, basta con ejecutar [./install.sh]
3. Descargar Pictogram del repositorio e iniciar instalación
```
$ git clone http://scm.ujaen.es/softuno/pictogram.git
$ git clone http://gitlab.ujaen.es/yotta/pictogram.git
$ cd pictogram/sails
$ sudo ./install.sh
```
......
#!/bin/bash
#
# - Encoding and locale for virtual machine
# - Build-essentials and g++
# - Ansible install
# - Run ansible playbook
#
# keymap and system encoding
echo "-- Configuring encoding and locale"
sudo localectl set-keymap es
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales
echo "-- Installing build-essentials and g++"
sudo apt-get update
sudo apt-get install build-essential g++
sudo apt-get update -y
sudo apt-get install -y build-essential g++
# installing ansible
echo "-- Installing ansible"
......@@ -42,3 +53,6 @@ else
echo "XX Playbook not found, provision not finished"
exit
fi
# overwrite sails-mysql
yes | sudo cp -rf /vagrant/src/node_modules_overwrite/sails-mysql/* /vagrant/src/node_modules/sails-mysql/
#!/bin/bash
#
# Install core pictos (symbolstx and upload)
#
cd /vagrant/
echo "--Descargando coleccion de pictogramas"
wget http://dev.yottacode.com/symbolstx.tgz.gpg
wget http://dev.yottacode.com/upload.tgz.gpg
wget https://dev.pictogramweb.com/symbolstx.tgz.gpg
wget https://dev.pictogramweb.com/upload.tgz.gpg
wget https://dev.pictogramweb.com/arasaac.tgz.gpg
echo "--Desencriptando coleccion"
echo r\"YjtnB+a4$.M*nJ | gpg --batch --no-tty --yes --passphrase-fd 0 symbolstx.tgz.gpg
echo r\"YjtnB+a4$.M*nJ | gpg --batch --no-tty --yes --passphrase-fd 0 upload.tgz.gpg
echo r\"YjtnB+a4$.M*nJ | gpg --batch --no-tty --yes --passphrase-fd 0 arasaac.tgz.gpg
echo "--Descomprimiendo coleccion"
tar zxvf /vagrant/symbolstx.tgz
tar zxvf /vagrant/upload.tgz
tar zxvf /vagrant/arasaac.tgz
echo "--Renombrado y borrado de archivos"
rm upload.tgz
rm upload.tgz.gpg
rm symbolstx.tgz
rm symbolstx.tgz.gpg
mv symbolstx_96x82 symbolstx
rm arasaac.tgz
rm arasaac.tgz.gpg
This diff could not be displayed because it is too large.
-- MySQL dump 10.13 Distrib 5.7.13, for Linux (x86_64)
--
-- Host: localhost Database: pictodbclean
-- ------------------------------------------------------
-- Server version 5.7.13
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `pictocat`
--
DROP TABLE IF EXISTS `pictocat`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pictocat` (
`id` int(11) NOT NULL,
`id_supercat` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Identifies a category, which, itself, may belong to another category';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `pictocat`
--
LOCK TABLES `pictocat` WRITE;
/*!40000 ALTER TABLE `pictocat` DISABLE KEYS */;
INSERT INTO `pictocat` VALUES (1,0),(2,1),(3,1),(4,0),(5,0),(6,1),(7,0),(8,1),(9,0),(10,0),(11,0),(12,0),(13,0),(14,0),(15,0),(16,0),(17,16),(18,16),(19,0),(20,0),(21,16),(22,0),(23,22),(24,16),(25,16),(26,0),(27,0),(28,0),(29,0),(30,29),(31,29),(32,29),(33,0),(34,0),(35,22),(36,0),(37,5),(38,0),(39,0),(40,12),(41,15),(42,0),(43,0),(44,0),(45,9),(46,0),(47,0),(48,0),(49,0),(50,0),(51,0),(52,0),(53,0),(54,53),(55,53),(56,53),(57,53),(58,53),(59,53),(60,53),(61,53),(62,53),(63,53),(64,53),(65,51),(66,20),(67,0),(68,0),(69,0),(70,0),(71,0),(72,20),(73,0),(74,0),(75,0),(76,71),(77,20),(78,51),(79,0),(80,0),(81,5),(82,22),(83,0),(84,0),(85,84),(86,84),(87,51),(88,0),(89,20),(90,0),(91,51),(92,80),(93,0),(94,0),(95,0),(96,0),(97,0),(98,97),(99,97),(100,80),(101,69),(102,51),(103,51),(104,0),(105,51),(106,69),(107,69),(108,0),(109,69),(110,69),(111,69),(112,69),(113,69),(114,0),(115,71),(116,0),(117,0),(118,0),(119,0),(120,0),(121,0),(122,0);
/*!40000 ALTER TABLE `pictocat` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-01-17 9:48:07
--
-- Creacion y volcado de datos para la tabla `pictocattree`
--
source /vagrant/roles/database/files/pictocat_tree_populate.sql
source /vagrant/roles/database/files/catexp.sql
......@@ -55,9 +55,8 @@ INSERT INTO `meta_instruction` (`id` ,`name` ,`objective` ,`id_met`, `lang`) VA
INSERT INTO `source` (`id`, `name`, `description`) VALUES
(1, 'SymbolStix', 'n2y SymbolStix pictograms collection'),
(2, 'Custom', 'Uploaded pictograms by a given user');
;
(2, 'Custom', 'Uploaded pictograms by a given user'),
(3, 'Arasaac', 'Arasaac pictograms collection');
--
-- Volcado de datos para la tabla `picto`
......
......@@ -48,17 +48,14 @@ COMMENT="This table registers and action performed by a user at a given time, al
--
-- Estructura de tabla para la tabla `catexp`
--
CREATE TABLE IF NOT EXISTS `catexp`(
CREATE TABLE `catexp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_cat` int(11) NOT NULL,
`lang` char(5),
`lang` char(5) DEFAULT NULL,
`exp` varchar(30) NOT NULL,
PRIMARY KEY(`id`),
UNIQUE(exp,lang),
CHECK (lang IN ('es-es','en-gb','en-us'))
)
COMMENT="Stores the expressions available in several languages for a given category (id_cat)";
PRIMARY KEY (`id`),
UNIQUE KEY `exp` (`exp`,`lang`)
) ENGINE=InnoDB AUTO_INCREMENT=27958 DEFAULT CHARSET=utf8 COMMENT='Stores the expressions available in several languages for a given category (id_cat)';
-- --------------------------------------------------------
--
......@@ -201,9 +198,9 @@ COMMENT="Stablish access rights to pictos";
CREATE TABLE IF NOT EXISTS `pictocat`(
`id` int(11) PRIMARY KEY,
`id_supercat` int(11)
`id_supercat` int(11) DEFAULT NULL
)
COMMENT="Identifies a category, which, itself, may belong to another category";
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT="Identifies a category, which, itself, may belong to another category";
-- --------------------------------------------------------
......@@ -375,6 +372,8 @@ CREATE TABLE IF NOT EXISTS `supervisor` (
`password` varchar(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Encrypted password using the BCrypt algorithm',
`id_off` int(11) DEFAULT NULL,
`active` boolean DEFAULT FALSE,
`arasaac_license` boolean DEFAULT FALSE,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
KEY `id_off` (`id_off`)
......
......@@ -24,13 +24,14 @@
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/symbolstix.sql"
- name: Imports symbolstix categories
- name: Imports arasaac pictos
mysql_db:
login_user: "{{ database_user }}"
login_password: "{{ database_user_passwd }}"
name: "{{ database_name }}"
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/pictocat.sql"
target: "{{ server_path }}/{{ database_files_relative_path }}/arasaac.sql"
- name: Imports application essential data
mysql_db:
......
......@@ -4,7 +4,7 @@ Changes to be performed manually in servers to upgrade
## AngularJS
(already done in dev)
(already done in dev & pre)
- angular-re-captcha has been replaced by angular-recaptcha, so bower has to be run
- reinstall ui-bootstrap
......@@ -15,6 +15,14 @@ Changes to be performed manually in servers to upgrade
(already done in dev)
- add arasaac to source table
`INSERT INTO `source` (`id`, `name`, `description`) VALUES (3, 'Arasaac', 'Arasaac pictograms collection');`
- alter table supervisor add arasaac license:
`ALTER TABLE supervisor ADD COLUMN arasaac_license BOOLEAN DEFAULT FALSE;`
- load arasaac.sql into MySQL
(already done in dev & pre)
- load pictocat_tree_populate.sql
`source /vagrant/roles/database/files/pictocat_tree_populate.sql;`
- reload trigers-enrolments-integrity-constraints.sql
......
......@@ -372,6 +372,70 @@ module.exports = {
},
/**
* Return all pictos from Arasaac using the language of the specified supervisor.
* @param {request} req {} (with supervisorId 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
* }
* ]
*/
fromArasaac: function (req, res) {
var l = [];
var fs = require('fs');
Supervisor.findOne({ id: req.params.id }).then(function (supervisor) {
if (supervisor) {
Picto.find({ source: 3})
.paginate({page: req.params.page, limit:req.params.limit})
.populate('expressions', { lang: supervisor.lang })
.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 from Arasaac in language " + supervisor.lang);
return res.ok(l);
}); // end async.eachSeries
})
.catch(() => res.badRequest());
} else {
return res.badRequest();
}
})
.catch(() => res.serverError());
},
/**
* Add a tag to an existing picto. This tag is associated to the supervisor.
* @param {request} req
* {
......
......@@ -95,24 +95,42 @@ module.exports = {
* @param {request} req {} (with studentId specified as url parameters)
* @param {response} res
* {
* id: 12,
* office: 1234,
* username: 'johnydoe',
* name: 'Johny',
* surname: 'Doe',
* birthdate: '2009-12-10T00:00:00.000Z',
* gender: 'F',
* country: 'ES',
* pic: 'avatar/nice/url.jpg',
* notes: null,
* lang: 'en-en',
* iat: 123512,
* exp: 1231292,
* attributes: { @see Student.getValidAttributes() },
* current_method: 'Do Things', // May be null
* current_instruction: 'Do Stuff', // May be null
* supervision: 0|1|2, // supervision level according to requester 0 -> office admin, 1 -> tutor, 2 -> therapist
* }
"office": 383,
"id": 92,
"username": "jose",
"name": "AAjose",
"surname": "AAjose antonio",
"birthdate": "2009-05-12T00:00:00.000Z",
"gender": "M",
"country": "ES",
"pic": "/upload/studentAvatar/defaultAvatar.jpg",
"notes": "",
"lang": "es-es",
"current_method": "Comunicación Aumentativa y Adaptativa", // May be "no method"
"current_instruction": "Fase 4 - Estructura de la oración", // May be "no instruction"
"supervision": 2 // supervision level according to requester 0 -> office admin, 1 -> tutor, 2 -> therapist, 3 -> student himself
"attributes": { @see Student.getValidAttributes()
"categories": true,
"input_feedback": {
"vibration": true,
"read": false,
"beep": false,
"highlight": false
},
"input_selection": {
"click": true,
"double_click": false,
"long_press": false,
"drag": true
},
"legend": false,
"legend_size": "normal",
"size": "large",
"picto_background": "#0000ff",
"tape_background": "#00ffff",
"delivery": 0
}
}
*/
getInfo: function (req, res) {
Student.findOne({id: req.params.id_stu})
......@@ -144,9 +162,9 @@ module.exports = {
else if (stu_sup && !req.token.office)
student.supervision = 1; // requester is tutor of the studend
else if (stu_sup && req.token.office && student.office == req.token.office.id)
student.supervision = 2; // requester is supervisor of student
else if (req.token.isStudent && req.token.id == student.id)
student.supervision = 3 // requester is the student himself
student.supervision = 2; // requester is supervisor of student
else if (req.token.isStudent && req.token.id == student.id)
student.supervision = 3 // requester is the student himself
if (student.supervision == -1) // should not hace access!!!
return res.forbidden("Access to this student should not be granted to you");
......@@ -966,7 +984,9 @@ module.exports = {
* legend: true/[false],
* legend_size: '[small]/large',
* expression: 'custom expression',
* color: any valid HEX color or [null]
* color: any valid HEX color or [null],
* sound_uri: path to sound file,
* user_avatar: email (supervisor) or username (student) for associated account
* }
* },
* }
......@@ -1079,9 +1099,23 @@ module.exports = {
});
},
// update action
// update picto atributes for a studentPicto
//
/**
Updates the legend for all pictos in the vocabulary according to following
values:
- 'none': no legend is visualized
- 'normal': legend is in pictogram's foot
- 'full': no image, just the expression
@params {request} req {
id_stu: {integer} studentID,
legend_value: {string} 'none' | 'normal' | 'full'
}
@params {response} res {
id: {integer} studentID,
legend_value: {string} 'none' | 'normal' | 'full'
}
*/
update_legend: function (req, res) {
var params = req.allParams();
Student.update_legend(params.id_stu, params.legend_value, function (err) {
......
......@@ -200,6 +200,32 @@ module.exports = {
},
/**
* Acept Arasaac License
* @param {request} req
* {
* "token": "12398123aas78sf798as7d987234" // Encryted code with supervisor ID, siging role and id_off
* }
*/
accept_arasaac: function (req, res) {
var params = req.params.all();
Supervisor.findOne(params.id)
.then(function (supervisor) {
if (!supervisor)
throw new Error("Error when looking for user");
supervisor.arasaacLicense = true;
delete supervisor.password;
supervisor.save();
res.ok();
})
.catch(function (err) {
return res.serverError(err.message ? err.message : 'Supervisor not found');
});
},
/**
* Gets a supervisor by his email
* @param {request} req {} (width email as url parameter)
* @param {response} res
......@@ -261,7 +287,7 @@ module.exports = {
create: function (req, res) {
var params = req.params.all();
var supervisor;
// Send email confirmation
function sendConfirmationMail(cb) {
......@@ -318,7 +344,7 @@ module.exports = {
return res.serverError("Supervisor created but returned null");
supervisor = sup;
if (params.role === 'therapist_office' || params.role === 'tutor_office') {
sendConfirmationMail((err) => {
if (err) throw err;
......
......@@ -168,8 +168,8 @@ module.exports = function roomsHook (sails) {
* Call from config/sockets.js after a socket disconnects
*/
disconnect: function(socket) {
var rooms = socketRooms[sails.sockets.getId(socket)];
if (!rooms) return;
var rooms = socketRooms[sails.sockets.getId(socket)];
if(!rooms) return;
for (var i = 0; i < rooms.length; i++)
sails.hooks.rooms.unsubscribeFromRoom(rooms[i].room, socket);
}
......
......@@ -90,6 +90,8 @@ module.exports = {
color: null,
expression: null,
legend: 'none',
uri_sound: null,
user_avatar: null
};
if (typeof attributes === 'object') {
......@@ -128,13 +130,19 @@ module.exports = {
}
if (!((/^(none|normal|full)$/).test(validAttributes.legend))) {
delete validAttributes.legend;
}
}
if (typeof validAttributes.highlight !== 'boolean') {
delete validAttributes.highlight;
}
if (!((/^#([0-9a-f]{3}){1,2}$/i).test(validAttributes.color))) {
delete validAttributes.color;
}
if (typeof validAttributes.sound_uri!== 'string') {
delete validAttributes.sound_uri;
}
if (typeof validAttributes.user_avatar !== 'string') {
delete validAttributes.user_avatar;
}
}
sails.log.verbose('Valid attributes for StuPicto', validAttributes);
return Object.assign({}, defaultAttributes, validAttributes);
......
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