issue #681 closed

parent 7cdc8b6f
...@@ -84,6 +84,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -84,6 +84,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @see PCBDBHelper#getCurrentUser() * @see PCBDBHelper#getCurrentUser()
*/ */
public void setCurrentUser(User user) { public void setCurrentUser(User user) {
Log.i(getClass().getCanonicalName(),"user "+user.get_name_stu()+" "+user.get_json_attrs());
this.currentUser = user; this.currentUser = user;
PCBcontext.getDevice().setLastStuId(user.get_id_stu()); PCBcontext.getDevice().setLastStuId(user.get_id_stu());
if (user.is_supervisor()) PCBcontext.getDevice().setLastSupId(user.get_id_sup()); if (user.is_supervisor()) PCBcontext.getDevice().setLastSupId(user.get_id_sup());
......
...@@ -67,7 +67,7 @@ public class NetService implements Runnable { ...@@ -67,7 +67,7 @@ public class NetService implements Runnable {
@Override @Override
public void error(Exception e) { public void error(Exception e) {
Log.e(this.getClass().getSimpleName(), "Error un when server login:" + e.getMessage()); Log.e(this.getClass().getSimpleName(), "Error un when server login:" + e.getMessage());
if (e instanceof LoginException) NetService.this.device.restart_app(); if (e instanceof LoginException) NetService.this.device.restart_app(false);
} }
}); });
else ServerLogin.login_student(user.get_nickname_stu(), user.get_pwd_stu(), new iRestapiListener() { else ServerLogin.login_student(user.get_nickname_stu(), user.get_pwd_stu(), new iRestapiListener() {
...@@ -89,19 +89,19 @@ public class NetService implements Runnable { ...@@ -89,19 +89,19 @@ public class NetService implements Runnable {
@Override @Override
public void error(Exception e) { public void error(Exception e) {
Log.e(this.getClass().getSimpleName(),"Error un when server login:"+e.getMessage()); Log.e(this.getClass().getSimpleName(),"Error un when server login:"+e.getMessage());
if (e instanceof LoginException) NetService.this.device.restart_app(); if (e instanceof LoginException) NetService.this.device.restart_app(false);
} }
}); });
} }
public boolean online() {return updated;} public boolean online() {return updated;}
public void restart_app() { public void restart_app(boolean direct_login) {
PCBcontext.unset_user(); PCBcontext.unset_user();
this.device.restart_app(); this.device.restart_app(direct_login);
} }
public void restart_app(Intent intent) { public void restart_app(Intent intent, boolean direct_login) {
PCBcontext.unset_user(); PCBcontext.unset_user();
this.device.restart_app(intent); this.device.restart_app(intent, direct_login);
} }
/** /**
......
...@@ -2,6 +2,8 @@ package com.yottacode.pictogram.net; ...@@ -2,6 +2,8 @@ package com.yottacode.pictogram.net;
import android.content.Intent; import android.content.Intent;
import com.yottacode.pictogram.dao.User;
/** /**
* Created by Fernando on 12/08/2016. * Created by Fernando on 12/08/2016.
*/ */
...@@ -10,7 +12,7 @@ public interface iNetServiceDevice { ...@@ -10,7 +12,7 @@ public interface iNetServiceDevice {
public void build(); public void build();
public void notifyStatus(boolean updated); public void notifyStatus(boolean updated);
public void closeNotifyStatus(); public void closeNotifyStatus();
public void restart_app(); public void restart_app(boolean direct_login);
public void restart_app(Intent intent); public void restart_app(Intent intent, boolean direct_login);
public void updateUserConfig(); public void updateUserConfig(User user);
} }
...@@ -73,9 +73,14 @@ public final class PCBcontext { ...@@ -73,9 +73,14 @@ public final class PCBcontext {
if (getNetService().online()) new StudentTalk(room, new iStudentListener[] {new iStudentListener() { if (getNetService().online()) new StudentTalk(room, new iStudentListener[] {new iStudentListener() {
@Override @Override
public void change(User updatedStudent) { public void change(User updatedStudent) {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent); PCBcontext.getDevice().insertUser(updatedStudent);
PCBcontext.getDevice().insertUser(updatedStudent); if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big())
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(); PCBcontext.getNetService().getNetServiceDevice().restart_app(true);
else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent);
}
} }
}}); }});
......
package com.yottacode.pictogram.tabletlibrary.gui; 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.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
...@@ -43,20 +39,11 @@ public class PictoGridAdapter extends ArrayAdapter { ...@@ -43,20 +39,11 @@ public class PictoGridAdapter extends ArrayAdapter {
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
return PictoItemViewGenerator.getPictoView( return PictoItemViewGenerator.getPictoView(
this.pictoLinkedList.get(position), this.pictoLinkedList.get(position),
convertView, convertView,
parent parent
); );
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void ttsPicto(Picto p, TextToSpeech tts) {
if (p.is_enabled()) {
String input = p.get_translation();
Bundle params = new Bundle();
params.putString(TextToSpeech.Engine.KEY_PARAM_VOLUME, "1");
tts.speak(input, TextToSpeech.QUEUE_FLUSH, params, null);
}
}
} }
...@@ -121,7 +121,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener { ...@@ -121,7 +121,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener {
this.count_deletelong = 0; this.count_deletelong = 0;
if (!PCBcontext.is_user_logged()) { if (!PCBcontext.is_user_logged()) {
Log.i(LOG_TAG,"No user logged. Restarting app"); Log.i(LOG_TAG,"No user logged. Restarting app");
PCBcontext.getNetService().restart_app(); PCBcontext.getNetService().restart_app(false);
return; return;
} }
...@@ -230,16 +230,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener { ...@@ -230,16 +230,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener {
}); });
((NetServiceTablet)PCBcontext.getNetService().getNetServiceDevice()).setPictogramActivity(this); ((NetServiceTablet)PCBcontext.getNetService().getNetServiceDevice()).setPictogramActivity(this);
setConfig();
this.generateAnimations();
if (this.currentCategory != null) {
this.hidePictoMainGridView();
} else {
this.showPictoMainGridView();
}
}
public void setConfig(){
if (PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big()) { if (PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big()) {
maxColumns= getResources().getInteger(R.integer.columns_big); maxColumns= getResources().getInteger(R.integer.columns_big);
maxRows= getResources().getInteger(R.integer.rows_big); maxRows= getResources().getInteger(R.integer.rows_big);
...@@ -249,14 +240,24 @@ public class PictogramActivity extends Activity implements iVocabularyListener { ...@@ -249,14 +240,24 @@ public class PictogramActivity extends Activity implements iVocabularyListener {
maxRows= getResources().getInteger(R.integer.rows); maxRows= getResources().getInteger(R.integer.rows);
maxInTape = getResources().getInteger(R.integer.maxInTape); maxInTape = getResources().getInteger(R.integer.maxInTape);
} }
this.pictoMainGridView.setNumColumns(this.maxColumns); PictogramActivity.this.pictoMainGridView.setNumColumns(PictogramActivity.this.maxColumns);
this.pictoCategoryGridView.setNumColumns(this.maxColumns); PictogramActivity.this.pictoCategoryGridView.setNumColumns(PictogramActivity.this.maxColumns);
startTTS(); setConfig();
this.generateAnimations();
setFeedback(new View[] {deleteButton,ttsButton, this.showPictoCategoriesViewButton, this.pictoCategoryGridView,this.pictoMainGridView}); if (this.currentCategory != null) {
this.hidePictoMainGridView();
} else {
this.showPictoMainGridView();
}
} }
public void setConfig(){
startTTS();
setFeedback(new View[] {deleteButton,ttsButton, this.showPictoCategoriesViewButton, this.pictoCategoryGridView,this.pictoMainGridView});
}
private void setFeedback(View views[]) { private void setFeedback(View views[]) {
boolean vibration=PCBcontext.getPcbdb().getCurrentUser().input_feedback_on(User.JSON_STUDENT_INPUT_FEEDBACK.VIBRATION); boolean vibration=PCBcontext.getPcbdb().getCurrentUser().input_feedback_on(User.JSON_STUDENT_INPUT_FEEDBACK.VIBRATION);
boolean click=PCBcontext.getPcbdb().getCurrentUser().input_feedback_on(User.JSON_STUDENT_INPUT_FEEDBACK.BEEP); boolean click=PCBcontext.getPcbdb().getCurrentUser().input_feedback_on(User.JSON_STUDENT_INPUT_FEEDBACK.BEEP);
...@@ -936,7 +937,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener { ...@@ -936,7 +937,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener {
} }
PictogramActivity.this.finish(); PictogramActivity.this.finish();
PCBcontext.getNetService().restart_app(serialActivity); PCBcontext.getNetService().restart_app(serialActivity,false);
} }
return false; return false;
} }
......
...@@ -216,7 +216,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -216,7 +216,7 @@ public class StudentFragmentGrid extends Fragment{
GUITools.show_alert(getActivity(), R.string.loginErrorTxt, getString(R.string.serverError), new GUITools.iOKListener() { GUITools.show_alert(getActivity(), R.string.loginErrorTxt, getString(R.string.serverError), new GUITools.iOKListener() {
@Override @Override
public void ok() { public void ok() {
PCBcontext.getNetService().restart_app(); PCBcontext.getNetService().restart_app(false);
} }
}); });
} }
...@@ -242,7 +242,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -242,7 +242,7 @@ public class StudentFragmentGrid extends Fragment{
GUITools.show_alert(getActivity(), R.string.loginErrorTxt,getString(R.string.noStudentsError), new GUITools.iOKListener() { GUITools.show_alert(getActivity(), R.string.loginErrorTxt,getString(R.string.noStudentsError), new GUITools.iOKListener() {
@Override @Override
public void ok() { public void ok() {
PCBcontext.getNetService().restart_app(); PCBcontext.getNetService().restart_app(false);
} }
}); });
......
...@@ -5,6 +5,7 @@ import android.content.Intent; ...@@ -5,6 +5,7 @@ import android.content.Intent;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.iNetServiceDevice; import com.yottacode.pictogram.net.iNetServiceDevice;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.PictogramActivity; import com.yottacode.pictogram.tabletlibrary.gui.PictogramActivity;
...@@ -68,7 +69,7 @@ public class NetServiceTablet implements iNetServiceDevice { ...@@ -68,7 +69,7 @@ public class NetServiceTablet implements iNetServiceDevice {
* the app. The most frequent reason is a password change while the user have been logged * the app. The most frequent reason is a password change while the user have been logged
* offline * offline
*/ */
public void restart_app(Intent serialActivity) { public void restart_app(Intent serialActivity, boolean direct_login) {
Log.i(this.getClass().getCanonicalName(),"App restarting"); Log.i(this.getClass().getCanonicalName(),"App restarting");
if (serialActivity==null) { if (serialActivity==null) {
...@@ -81,15 +82,14 @@ public class NetServiceTablet implements iNetServiceDevice { ...@@ -81,15 +82,14 @@ public class NetServiceTablet implements iNetServiceDevice {
} }
serialActivity = new Intent(PCBcontext.getContext(), serialClass); serialActivity = new Intent(PCBcontext.getContext(), serialClass);
} }
serialActivity.putExtra("resetPrevUser", true); serialActivity.putExtra("resetPrevUser", !direct_login);
Log.e(this.getClass().getCanonicalName(),"resetPrevUser:"+serialActivity.getBooleanExtra("resetPrevUser", true));
PCBcontext.getContext().startActivity(serialActivity); PCBcontext.getContext().startActivity(serialActivity);
} }
public void restart_app() {restart_app(null);} public void restart_app(boolean direct_login) {restart_app(null, direct_login);}
public void setPictogramActivity(PictogramActivity pictogramActivity) {this.pictogramActivity=pictogramActivity;} public void setPictogramActivity(PictogramActivity pictogramActivity) {this.pictogramActivity=pictogramActivity;}
public void updateUserConfig() { public void updateUserConfig(User user) {
this.pictogramActivity.setConfig(); this.pictogramActivity.setConfig();
this.pictogramActivity.refresh();
} }
} }
...@@ -73,14 +73,6 @@ ...@@ -73,14 +73,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/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/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
...@@ -89,6 +81,14 @@ ...@@ -89,6 +81,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/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/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......
...@@ -4,6 +4,7 @@ import android.content.Intent; ...@@ -4,6 +4,7 @@ import android.content.Intent;
import android.util.Log; import android.util.Log;
import android.widget.TextView; import android.widget.TextView;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.iNetServiceDevice; import com.yottacode.pictogram.net.iNetServiceDevice;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.watch.R; import com.yottacode.pictogram.watch.R;
...@@ -41,18 +42,18 @@ public class NetServiceWatch implements iNetServiceDevice { ...@@ -41,18 +42,18 @@ public class NetServiceWatch implements iNetServiceDevice {
* the app. The most frequent reason is a password change while the user have been logged * the app. The most frequent reason is a password change while the user have been logged
* offline * offline
*/ */
public void restart_app() { public void restart_app(boolean direct_login) {
restart_app(new Intent(PCBcontext.getContext(), Activity)); restart_app(new Intent(PCBcontext.getContext(), Activity), direct_login);
} }
@Override @Override
public void restart_app(Intent intent) { public void restart_app(Intent intent, boolean direct_login) {
intent.putExtra("resetPrevUser", true); intent.putExtra("resetPrevUser", !direct_login);
PCBcontext.getContext().startActivity(intent); PCBcontext.getContext().startActivity(intent);
} }
@Override @Override
public void updateUserConfig() { public void updateUserConfig(User user) {
} }
......
...@@ -18,6 +18,7 @@ android { ...@@ -18,6 +18,7 @@ android {
targetSdkVersion 22 targetSdkVersion 22
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
resValue "string","SerialClass","com.yottacode.pictogram.tabletlibrary.gui.SerialActivity"
// signingConfig signingConfigs.config // signingConfig signingConfigs.config
} }
productFlavors { productFlavors {
......
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