Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fe325bdc
authored
Aug 25, 2017
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issue
#313
closed
parent
1649886a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
13 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/User.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/websockets/StudentTalk.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/User.java
View file @
fe325bdc
...
@@ -2,6 +2,7 @@ package com.yottacode.pictogram.dao;
...
@@ -2,6 +2,7 @@ package com.yottacode.pictogram.dao;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.util.Log
;
import
com.yottacode.pictogram.tools.Img
;
import
com.yottacode.pictogram.tools.Img
;
...
@@ -247,6 +248,7 @@ public class User {
...
@@ -247,6 +248,7 @@ public class User {
}
}
}
}
/**
/**
* @return The id of the active scene of this student
* @return The id of the active scene of this student
*/
*/
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/websockets/StudentTalk.java
View file @
fe325bdc
...
@@ -31,7 +31,7 @@ public class StudentTalk implements Emitter.Listener {
...
@@ -31,7 +31,7 @@ public class StudentTalk implements Emitter.Listener {
if
(
PCBcontext
.
getPcbdb
()!=
null
)
if
(
PCBcontext
.
getPcbdb
()!=
null
)
try
{
try
{
JSONObject
msg
=
((
JSONObject
)
args
[
0
]).
getJSONObject
(
"student"
);
JSONObject
msg
=
((
JSONObject
)
args
[
0
]).
getJSONObject
(
"student"
);
Log
.
i
(
this
.
getClass
().
getName
(),
"raw Received message "
+
msg
.
toString
());
Log
.
d
(
this
.
getClass
().
getName
(),
"raw Received message "
+
msg
.
toString
());
int
id
=
msg
.
getInt
(
"id"
);
int
id
=
msg
.
getInt
(
"id"
);
String
username
=
msg
.
getString
(
"username"
);
String
username
=
msg
.
getString
(
"username"
);
String
name
=
msg
.
getString
(
"name"
);
String
name
=
msg
.
getString
(
"name"
);
...
@@ -41,13 +41,13 @@ public class StudentTalk implements Emitter.Listener {
...
@@ -41,13 +41,13 @@ public class StudentTalk implements Emitter.Listener {
String
pic
=
msg
.
getString
(
"pic"
);
String
pic
=
msg
.
getString
(
"pic"
);
String
lang
=
msg
.
getString
(
"lang"
);
String
lang
=
msg
.
getString
(
"lang"
);
String
attributes
=
msg
.
getString
(
"attributes"
);
String
attributes
=
msg
.
getString
(
"attributes"
);
JSONObject
license
=
msg
.
getJSONObject
(
"license"
);
User
user
=
PCBcontext
.
getPcbdb
().
getCurrentUser
();
User
user
=
PCBcontext
.
getPcbdb
().
getCurrentUser
();
User
updatedUser
=
new
User
(
id
,
username
,
user
.
get_pwd_stu
(),
name
,
surname
,
id_active_scene
,
pic
,
gender
,
lang
,
attributes
,
User
updatedUser
=
new
User
(
id
,
username
,
user
.
get_pwd_stu
(),
name
,
surname
,
id_active_scene
,
pic
,
gender
,
lang
,
attributes
,
user
.
get_id_sup
(),
user
.
get_email_sup
(),
user
.
get_pwd_sup
(),
user
.
get_name_sup
(),
user
.
get_surname_sup
(),
user
.
get_url_img_sup
(),
user
.
get_gender_sup
(),
user
.
get_id_sup
(),
user
.
get_email_sup
(),
user
.
get_pwd_sup
(),
user
.
get_name_sup
(),
user
.
get_surname_sup
(),
user
.
get_url_img_sup
(),
user
.
get_gender_sup
(),
user
.
get_lang_sup
(),
user
.
get_tts_engine_sup
(),
user
.
get_office
());
user
.
get_lang_sup
(),
user
.
get_tts_engine_sup
(),
user
.
get_office
());
Log
.
i
(
this
.
getClass
().
getName
(),
"Attributes"
+
attributes
+
" listeners:"
+
listeners
.
length
);
for
(
iStudentListener
listener:
listeners
)
for
(
iStudentListener
listener:
listeners
)
listener
.
change
(
updatedUser
);
listener
.
change
(
updatedUser
,
license
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
e
.
getClass
().
getCanonicalName
()
+
"--"
+
e
);
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
e
.
getClass
().
getCanonicalName
()
+
"--"
+
e
);
...
@@ -61,6 +61,6 @@ public class StudentTalk implements Emitter.Listener {
...
@@ -61,6 +61,6 @@ public class StudentTalk implements Emitter.Listener {
* @version 1.0
* @version 1.0
*/
*/
public
interface
iStudentListener
{
public
interface
iStudentListener
{
void
change
(
User
updatedStudent
);
void
change
(
User
updatedStudent
,
JSONObject
license
);
}
}
}
}
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
View file @
fe325bdc
package
com
.
yottacode
.
pictogram
.
tools
;
package
com
.
yottacode
.
pictogram
.
tools
;
import
android.app.AlertDialog
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.util.Log
;
import
android.util.Log
;
import
com.yottacode.net.RestapiWrapper
;
import
com.yottacode.net.RestapiWrapper
;
...
@@ -17,6 +19,9 @@ import com.yottacode.pictogram.net.NetService;
...
@@ -17,6 +19,9 @@ import com.yottacode.pictogram.net.NetService;
import
com.yottacode.pictogram.net.websockets.Room
;
import
com.yottacode.pictogram.net.websockets.Room
;
import
com.yottacode.pictogram.net.websockets.StudentTalk
;
import
com.yottacode.pictogram.net.websockets.StudentTalk
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
public
final
class
PCBcontext
{
public
final
class
PCBcontext
{
private
static
Context
context
;
private
static
Context
context
;
private
static
PCBDBHelper
pcbdb
;
private
static
PCBDBHelper
pcbdb
;
...
@@ -75,16 +80,33 @@ public final class PCBcontext {
...
@@ -75,16 +80,33 @@ public final class PCBcontext {
studentTalk
=
new
StudentTalk
(
room
,
new
StudentTalk
.
iStudentListener
[]
{
new
StudentTalk
.
iStudentListener
()
{
studentTalk
=
new
StudentTalk
(
room
,
new
StudentTalk
.
iStudentListener
[]
{
new
StudentTalk
.
iStudentListener
()
{
@Override
@Override
public
void
change
(
User
updatedStudent
)
{
public
void
change
(
User
updatedStudent
,
JSONObject
license
)
{
try
{
PCBcontext
.
getDevice
().
insertUser
(
updatedStudent
);
if
(!
license
.
getBoolean
(
"isValid"
))
{
AlertDialog
.
Builder
builder1
=
new
AlertDialog
.
Builder
(
activityContext
);
if
(
updatedStudent
.
is_picto_size_big
()!=
getPcbdb
().
getCurrentUser
().
is_picto_size_big
()
||
PCBcontext
.
getVocabulary
().
has_categories
()
!=
vocabulary
.
has_categories
()
builder1
.
setMessage
(
R
.
string
.
loginNoLicenseMsg
);
||
updatedStudent
.
get_active_scene
()
!=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_scene
()){
builder1
.
setPositiveButton
(
R
.
string
.
accept
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
dialog
.
cancel
();
PCBcontext
.
getNetService
().
restart_app
(
false
);
}
});
AlertDialog
alert11
=
builder1
.
create
();
alert11
.
show
();
return
;
}
}
catch
(
JSONException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"No license attr! "
+
license
.
toString
());
}
PCBcontext
.
getDevice
().
insertUser
(
updatedStudent
);
if
(
updatedStudent
.
is_picto_size_big
()!=
getPcbdb
().
getCurrentUser
().
is_picto_size_big
()
||
PCBcontext
.
getVocabulary
().
has_categories
()
!=
vocabulary
.
has_categories
()
||
updatedStudent
.
get_active_scene
()
!=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_scene
())
PCBcontext
.
getNetService
().
restart_app
(
false
);
PCBcontext
.
getNetService
().
restart_app
(
false
);
else
{
}
else
{
PCBcontext
.
getPcbdb
().
setCurrentUser
(
updatedStudent
);
PCBcontext
.
getPcbdb
().
setCurrentUser
(
updatedStudent
);
PCBcontext
.
getNetService
().
getNetServiceDevice
().
updateUserConfig
(
updatedStudent
);
PCBcontext
.
getNetService
().
getNetServiceDevice
().
updateUserConfig
(
updatedStudent
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment