Commit 9a113ef3 by Arturo Montejo Ráez

Merge branch 'develop'

parents 2cf0049d 2b821b15
......@@ -26,12 +26,18 @@ public class User {
public final static class JSON_STUDENT_ATTTRS{
static String CATEGORIES = "categories";
static String INPUT_FEEDBACK = "input feedback";
static String INPUT_FEEDBACK = "input_feedback";
static String INPUT_SELECTION = "input selection";
static String PICTOGRAM_SIZE ="pictogram size";
static String TTS_ENGINE = "tts engine";
static String TTS_VOICE = "tts voice";
}
public final static class JSON_STUDENT_INPUT_FEEDBACK {
public static String VIBRATION="vibration";
public static String BEEP="beep";
public static String READ="read";
public static String HIGHLIGHT="highlight";
}
private Img img_stu;
private String nickname_stu, pwd_stu, name_stu, surname_stu, gender_stu, lang_stu;
private JSONObject attributes_stu;
......@@ -244,11 +250,11 @@ public class User {
*
* @return input feedback of the student configuration (default: "vibration")
*/
public String get_input_feedback() {
public boolean input_feedback_on(String input_feedback) {
try {
return this.attributes_stu.getString(JSON_STUDENT_ATTTRS.INPUT_FEEDBACK);
return this.attributes_stu.getJSONObject(JSON_STUDENT_ATTTRS.INPUT_FEEDBACK).getBoolean(input_feedback);
} catch (JSONException e) {
return "vibration";
return false;
}
}
......@@ -268,11 +274,11 @@ public class User {
/**
*
* @return pictogram size of the student configuration (default: "normal")
* @return pictogram size of the student configuration (default: "big")
*/
public boolean is_picto_size_big() {
try {
return !get_json_attr(JSON_STUDENT_ATTTRS.PICTOGRAM_SIZE).equals("normal");
return !get_json_attr(JSON_STUDENT_ATTTRS.PICTOGRAM_SIZE).equals("small");
} catch (Exception e) {
return true;
}
......
package com.yottacode.pictogram.tts;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.content.Context;
import android.speech.tts.UtteranceProgressListener;
import android.speech.tts.Voice;
import android.util.Log;
import android.widget.ArrayAdapter;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
/**
* PCB TTS service
* @author Fernando Martinez Santiago
* @version 1.0
*/
public class TTSHelper {
public class TTSHelper {
TextToSpeech ttobj;
public boolean engine_ok;
public boolean voice_ok=true;
Voice voice;
boolean voice_ok;
public void createTTS(Context context, String engine) {
this.destroy();
/* this.ttobj = new TextToSpeech(
context,
new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status != TextToSpeech.ERROR) {
ttobj.setLanguage(Locale.getDefault());
}
}
}, engine);*/
this.engine_ok=true;
Log.e(context.getApplicationInfo().processName,"TTS engine "+engine+" loaded");
}
public TTSHelper(Context context) {
createTTS(context ,null);
}
public void createTTS(final Context context, String engine, final Locale locale, final String voice) {
public TTSHelper(Context context, String engine) {
try {
createTTS(context ,engine);
}catch (Exception e) {
createTTS(context ,null);
Log.e(context.getApplicationInfo().processName, "Engine "+engine+" error",e);
this.engine_ok=false;
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) {
createTTS(context ,engine,locale,voice);
}
}
public void setOnUtteranceProgressListener(UtteranceProgressListener listener) {
this.ttobj.setOnUtteranceProgressListener(listener);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setVoice(Context context, String voice) {
......@@ -62,11 +55,10 @@ public class TTSHelper {
Set<Voice> voices = this.ttobj.getVoices();
if (voices!=null)
for (Voice avoice : voices) {
Log.e(context.getApplicationInfo().processName,"Voice name "+avoice.getName());
if (avoice.getName().compareTo(voice) == 0) {
if (avoice.getName().equalsIgnoreCase(voice)) {
this.ttobj.setVoice(avoice);
this.voice_ok=true;
Log.e(context.getApplicationInfo().processName,"Voice "+voice+" loaded");
Log.i(context.getApplicationInfo().processName,"Voice "+voice+" loaded");
break;
}
}
......@@ -79,7 +71,7 @@ public class TTSHelper {
}
public boolean isVoice_ok() { return this.voice_ok;}
public boolean isEngine_ok() { return this.engine_ok;}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void speakText(String toSpeak){
this.ttobj.speak(toSpeak, TextToSpeech.QUEUE_FLUSH,null, toSpeak.hashCode()+"");
......@@ -110,6 +102,29 @@ public class TTSHelper {
}
}
public void show( ) {
int i=0;
List<TextToSpeech.EngineInfo> engines = this.ttobj.getEngines();
for (Iterator<TextToSpeech.EngineInfo> iter = engines.iterator(); iter.hasNext(); ) {
TextToSpeech.EngineInfo element = iter.next();
Log.i("TTSHelper","TTS: "+element.name + " label:"+element.label);
}
if (this.ttobj.getVoice()!=null) {
Log.i("TTSHelper", "Default voice:" + this.ttobj.getDefaultVoice().getName());
Set<Voice> voices = this.ttobj.getVoices();
if (voices != null)
for (Voice voice : voices) {
Log.i("TTSHelper", "Voice: " + voice.getName() + " locale:" + voice.getLocale()+" features:"+voice.getFeatures());
}
}
}
public void destroy() {
if(ttobj !=null){
......@@ -119,4 +134,10 @@ public class TTSHelper {
this.ttobj=null;
}
}
\ No newline at end of file
public void play(String input) {
Bundle params = new Bundle();
params.putString(TextToSpeech.Engine.KEY_PARAM_VOLUME, "1");
params.putString(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "TAPE_READ");
ttobj.speak(input, TextToSpeech.QUEUE_FLUSH, params, "TAPE_READ");
}
}
......@@ -63,4 +63,9 @@
<!--mirror mode-->
<string name="mirror_mode_off">Mirror mode off</string>
<string name="mirror_mode_on">Mirror mode on</string>
<!--default tts engine and voice-->
<string name="default_tts_engine">com.google.android.tts</string>
<string name="default_tts_voice_male">en-gb-x-rjs#male_1-local</string>
<string name="default_tts_voice_female">en-gb-x-fis#female_1-local</string>
</resources>
......@@ -64,5 +64,10 @@
<string name="mirror_mode_off">Modo espejo desactivado</string>
<string name="mirror_mode_on">Modo espejo activado</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>
<string name="default_tts_voice_female">es-es-x-ana#female_2-local</string>
</resources>
......@@ -79,4 +79,9 @@
<!--mirror mode-->
<string name="mirror_mode_off">Modo espejo desactivado</string>
<string name="mirror_mode_on">Modo espejo activado</string>
<!--default tts engine and voice-->
<string name="default_tts_engine">com.google.android.tts</string>
<string name="default_tts_voice_male">en-gb-x-rjs#male_1-local</string>
<string name="default_tts_voice_female">en-gb-x-fis#female_1-local</string>
</resources>
......@@ -106,14 +106,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
......@@ -122,8 +114,17 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/24.2.1/jars" />
......
......@@ -22,8 +22,10 @@ public class PictoItemViewGenerator {
public static final int LAYOUT = R.layout.picto_grid_item;
public static final int LAYOUT_BIG = R.layout.picto_grid_item_big;
public static int mirror_color=0;
public static View getPictoView(Picto picto, View convertView, ViewGroup parent) {
return getPictoView(picto, convertView, parent, false);
}
public static View getPictoView(Picto picto, View convertView, ViewGroup parent, boolean preventMirror) {
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? LAYOUT_BIG : LAYOUT, parent, false);
}
......@@ -86,10 +88,10 @@ public class PictoItemViewGenerator {
layout.setBackgroundColor(picto.get_color());
}
if (picto.is_mirror()) {
if (picto.is_mirror() && !preventMirror) {
int color[]={Color.WHITE,Color.LTGRAY,Color.GRAY,Color.DKGRAY,Color.BLACK,Color.DKGRAY,Color.GRAY,Color.LTGRAY,Color.WHITE};
float scale[]={1f,1.1f,1.2f,1.3f,1.4f,1.6f,1.3f,1.2f,1.1f};
float scale[]={1f,1.1f,1.2f,1.3f,1.4f,1.5f,1.4f,1.3f,1.2f,1.1f};
mirror_color++;
pictoImage.setScaleX(scale[mirror_color%scale.length]);
pictoImage.setScaleY(scale[mirror_color%scale.length]);
......
......@@ -4,7 +4,6 @@ import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
......@@ -70,7 +69,6 @@ public class SerialActivity extends Activity {
// Escribo el último valor indicado de username
mSerialViewMail.setText(username);
Log.e(this.getClass().getCanonicalName(),"resetPrevUser:"+getIntent().getBooleanExtra("resetPrevUser", true));
if (!username.equals("") && !password.equals("") && !getIntent().getBooleanExtra("resetPrevUser", true)) new UserLogin().login(username, password,SerialActivity.this, PictogramActivity.class, LoginActivity.class);
Button mEntrarButton = (Button) findViewById(R.id.entrar_button);
......
......@@ -3,14 +3,13 @@ package com.yottacode.pictogram.tabletlibrary.gui;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tts.TTSHelper;
import java.util.Iterator;
import java.util.LinkedList;
......@@ -19,6 +18,7 @@ public class TapeAdapter extends BaseAdapter {
//private Context mContext;
private LinkedList<Picto> pictoLinkedList;
private boolean play=false;
public TapeAdapter(){
//mContext = c;
......@@ -63,8 +63,9 @@ public class TapeAdapter extends BaseAdapter {
}
// ELIMINAR TODOS LOS ITEMS DEL ADAPTADOR
public void deleteAll(){
public void endPlay(){
pictoLinkedList.clear();
play=false;
}
// DEVUELVE TODOS LOS ELEMENTOS
......@@ -98,16 +99,17 @@ public class TapeAdapter extends BaseAdapter {
return PictoItemViewGenerator.getPictoView(
this.pictoLinkedList.get(position),
convertView,
parent
);
parent,true);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void ttsAllNew(TextToSpeech tts) {
public void ttsAllNew(TTSHelper tts) {
this.play=true;
String input = getAllAsString();
Bundle params = new Bundle();
params.putString(TextToSpeech.Engine.KEY_PARAM_VOLUME, "1");
params.putString(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "TAPE_READ");
tts.speak(input, TextToSpeech.QUEUE_FLUSH, params, "TAPE_READ");
tts.play(input);
}
public boolean play() {
return this.play;
}
}
......@@ -73,14 +73,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
......@@ -89,6 +81,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......
......@@ -157,8 +157,8 @@ module.exports = {
categories: true,
input_feedback: {
vibration: true,
click: false,
read: false,
beep: false,
highlight: false,
},
input_selection: {
......@@ -189,7 +189,7 @@ module.exports = {
if (typeof validAttributes.input_feedback !== 'object') {
delete validAttributes.input_feedback;
} else {
['vibration', 'click', 'read', 'highlight'].forEach((attribute) => {
['vibration', 'read', 'highlight', 'beep'].forEach((attribute) => {
if (typeof validAttributes.input_feedback[attribute] !== 'boolean') {
delete validAttributes.input_feedback[attribute];
}
......
......@@ -190,12 +190,12 @@
<div class="input-group">
<span class="input-group-addon">
<input type="radio"
value="normal"
id="studentSetupPictoSizeNormal"
value="small"
id="studentSetupPictoSizeSmall"
ng-model="studentData.attributes.size"
ng-change="update_attributes()">
</span>
<label class="form-control" for="studentSetupPictoSizeNormal">
<label class="form-control" for="studentSetupPictoSizeSmall">
{{ 'small' | translate }}
</label>
</div>
......@@ -213,7 +213,6 @@
</div>
</div>
</fieldset>
<!-- DISABLED, NOT IMPLEMENTED YET
<fieldset>
<legend>{{ 'feedback_picto' | translate }}</legend>
<div class="input-group">
......@@ -228,11 +227,11 @@
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox"
id="studentSetupClickOnTouch"
ng-model="studentData.attributes.input_feedback.click"
id="studentSetupBeepOnTouch"
ng-model="studentData.attributes.input_feedback.beep"
ng-change="update_attributes()">
</span>
<label class="form-control" for="studentSetupClickOnTouch">{{ 'click' | translate }}</label>
<label class="form-control" for="studentSetupBeepOnTouch">{{ 'beep' | translate }}</label>
</div>
<div class="input-group">
<span class="input-group-addon">
......@@ -255,6 +254,7 @@
</label>
</div>
</fieldset>
<!-- DISABLED, NOT IMPLEMENTED YET
<fieldset>
<legend>{{ 'input_selection' | translate }}</legend>
<div class="input-group">
......
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