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
9123e619
authored
Jun 30, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issues
#471
,
#73
,
#474
closed
parent
44de29f5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
34 deletions
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/Room.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Device.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/LoginActivity.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/PictogramActivity.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/NetService.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
android/Pictogram/app/src/main/res/raw/pcbdb_create.sql
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/Room.java
View file @
9123e619
...
...
@@ -49,21 +49,7 @@ public class Room {
final
String
attributes_param
=
"attributes"
;
return
new
JSONObject
().
put
(
action_param
,
action
).
put
(
attributes_param
,
attributes
);
}
/* public void emit(String url, final Action action) {
Log.i(this.getClass().getName(), "Action: " + action.get_type() + " / Attributes emitted: " + action.get_json().toString());
try{
this.socket.emit(url, this.common_data(action.get_type(), action.get_json()), new Ack() {
@Override
public void call(Object... args) {
Log.i(this.getClass().getName(), "Ack");
for (Object arg : args)
Log.i(this.getClass().getName(), "Ack messsage:" + arg);
}
});
} catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(), e.getClass().getCanonicalName() + e.getMessage() + "--" + e.getLocalizedMessage());
}
}*/
public
void
emit
(
final
Action
action
)
{
String
token
=
PCBcontext
.
getRestapiWrapper
().
getToken
();
final
String
token_param
=
"token"
;
...
...
@@ -122,6 +108,10 @@ public class Room {
}
catch
(
Exception
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
e
.
getMessage
());
}
}
public
void
finalize
()
throws
java
.
lang
.
Throwable
{
super
.
finalize
();
if
(
this
.
socket
!=
null
)
this
.
socket
.
destroy
();
}
}
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Device.java
View file @
9123e619
...
...
@@ -234,7 +234,7 @@ public class Device extends SQLiteOpenHelper {
/**
* @param auser
* @param apwd
* @return
the information of an specific user, if they are
available in the local DB
* @return
information of a specific user, if it is
available in the local DB
*/
public
Vector
<
User
>
findUser
(
String
auser
,
String
apwd
)
throws
JSONException
,
LoginException
{
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
...
...
@@ -303,7 +303,7 @@ public class Device extends SQLiteOpenHelper {
db
.
execSQL
(
"INSERT INTO users_detail values ("
+
user
.
get_id_stu
()
+
", "
+
"'"
+
user
.
get_nickname_stu
()
+
"', "
+
(
user
.
get_pwd_stu
()==
null
?
"NULL"
:
(
"'"
+
user
.
get_pwd_stu
()
+
"'"
))+
", "
+
(
user
.
get_pwd_stu
()==
null
||
user
.
get_pwd_stu
().
length
()==
0
?
"NULL"
:
"'"
+
user
.
get_pwd_stu
()+
"'"
)
+
", "
+
"'"
+
user
.
get_name_stu
()
+
"', "
+
"'"
+
user
.
get_surname_stu
()
+
"', "
+
"'"
+
user
.
get_url_img_stu
()
+
"', "
+
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/LoginActivity.java
View file @
9123e619
...
...
@@ -69,7 +69,7 @@ public class LoginActivity extends FragmentActivity {
final
Vector
<
Img
>
imgs
=
new
Vector
<>(
1
);
imgs
.
add
(
new
Img
(
this
.
getIntent
().
getIntExtra
(
"id"
,
-
1
),
this
.
getIntent
().
getIntExtra
(
"
sup_
id"
,
-
1
),
this
.
getIntent
().
getStringExtra
(
"pic"
),
Img
.
SUPERVISOR
));
...
...
@@ -77,9 +77,10 @@ public class LoginActivity extends FragmentActivity {
@Override
public
void
loadComplete
()
{
try
{
supervisorPhotoView
.
setImageBitmap
(
supervisorPhotoView
.
setImageBitmap
(
imgs
.
get
(
0
).
get_bitmap
(
PCBcontext
.
getContext
())
);
supervisorPhotoView
.
invalidate
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/PictogramActivity.java
View file @
9123e619
...
...
@@ -600,7 +600,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
Picto
p
=
getCurrentPictoGridAdapter
().
getItem
(
position
);
if
(
p
==
null
)
{
// No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device si no es categoria
if
(
currentCategory
!=
null
)
{
if
(
currentCategory
!=
null
||
!
PCBcontext
.
getPcbdb
().
getCurrentUser
().
has_categories
()
)
{
Log
.
d
(
LOG_TAG
,
"No tengo pictograma. Abro carrete..."
);
int
cols
=
getResources
().
getInteger
(
R
.
integer
.
columns
);
addPicto
(
position
%
cols
,
(
int
)
(
position
/
cols
));
...
...
@@ -714,6 +714,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
count_deletelong
++;
if
(
count_deletelong
>=
3
)
{
PCBcontext
.
unset_user
();
// Paso un parámetro a la SerialActivity, para controlar de dónde viene
Intent
serialActivity
=
new
Intent
(
getBaseContext
(),
SerialActivity
.
class
);
serialActivity
.
putExtra
(
"resetPrevUser"
,
true
);
...
...
@@ -772,7 +773,9 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
builder
.
setPositiveButton
(
"OK"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
int
cat
=
PictogramActivity
.
this
.
currentCategory
!=
null
?
PictogramActivity
.
this
.
currentCategory
.
get_id
()
:
Picto
.
NO_CATEGORY
;
int
cat
=
PictogramActivity
.
this
.
currentCategory
!=
null
||
!
PCBcontext
.
getPcbdb
().
getCurrentUser
().
has_categories
()
?
PictogramActivity
.
this
.
currentCategory
.
get_id
()
:
Picto
.
NO_CATEGORY
;
PCBcontext
.
getVocabulary
().
saveLocalPicto
(
selectedImagePath
,
input
.
getText
().
toString
(),
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
View file @
9123e619
...
...
@@ -142,6 +142,9 @@ public class SerialActivity extends Activity {
}
else
{
Intent
loginActivity
=
new
Intent
(
SerialActivity
.
this
,
LoginActivity
.
class
);
loginActivity
.
putExtra
(
"sup_id"
,
localUsers
.
elementAt
(
0
).
get_id_sup
());
loginActivity
.
putExtra
(
"name"
,
localUsers
.
elementAt
(
0
).
get_name_sup
());
loginActivity
.
putExtra
(
"surname"
,
localUsers
.
elementAt
(
0
).
get_surname_sup
());
loginActivity
.
putExtra
(
"pic"
,
localUsers
.
elementAt
(
0
).
get_url_img_sup
());
loginActivity
.
putExtra
(
"offline"
,
true
);
startActivity
(
loginActivity
);
}
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/NetService.java
View file @
9123e619
...
...
@@ -152,7 +152,8 @@ public class NetService implements Runnable {
}
});
}
private
void
notifyStatus
()
{
public
void
notifyStatus
()
{
int
notifyID
=
1
;
String
user
=
""
;
if
(
PCBcontext
.
getPcbdb
()!=
null
)
{
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
View file @
9123e619
...
...
@@ -68,7 +68,7 @@ public final class PCBcontext {
}
/**
* @param student
@TODO user is not student
* @param student
* @param listener
*/
public
static
void
set_user
(
User
student
,
String
token
,
iImgDownloaderListener
listener
)
{
...
...
@@ -83,8 +83,18 @@ public final class PCBcontext {
room
=
new
Room
();
actionLog
=
new
ActionLog
();
vocabulary
=
new
Vocabulary
(
listener
);
}
getNetService
().
notifyStatus
();
}
/**
*
*/
public
static
void
unset_user
()
{
pcbdb
=
null
;
room
=
null
;
vocabulary
=
null
;
getNetService
().
notifyStatus
();
}
/**
* if the user becomes from offline to online and the login is failed, then the user relogin in
* the app. The most frequent reason is a password change while the user have been logged
...
...
android/Pictogram/app/src/main/res/raw/pcbdb_create.sql
View file @
9123e619
...
...
@@ -196,7 +196,7 @@ END
CREATE
TRIGGER
trg_insert_users_detail
INSTEAD
OF
INSERT
ON
users_detail
FOR
EACH
ROW
WHEN
NEW
.
pwd_stu
IS
NOT
NULL
WHEN
NEW
.
pwd_stu
NOT
IS
NULL
BEGIN
INSERT
OR
REPLACE
INTO
student
VALUES
(
NEW
.
id_stu
,
NEW
.
nickname_stu
,
NEW
.
pwd_stu
,
NEW
.
name_stu
,
NEW
.
surname_stu
,
NEW
.
url_img_stu
,
NEW
.
gender_stu
,
NEW
.
lang_stu
,
NEW
.
attributes_stu
);
INSERT
OR
REPLACE
INTO
supervisor
VALUES
(
NEW
.
id_sup
,
NEW
.
email_sup
,
NEW
.
pwd_sup
,
NEW
.
name_sup
,
NEW
.
surname_sup
,
NEW
.
url_img_sup
,
NEW
.
gender_sup
,
NEW
.
lang_sup
,
NEW
.
tts_engine_sup
);
...
...
@@ -204,20 +204,19 @@ BEGIN
END
;
--
CREATE
TRIGGER
trg_insert_users_detail_
nostudentpwd
CREATE
TRIGGER
trg_insert_users_detail_
knonwstudent
INSTEAD
OF
INSERT
ON
users_detail
FOR
EACH
ROW
WHEN
NEW
.
pwd_stu
IS
NULL
BEGIN
INSERT
OR
REPLACE
INTO
student
(
id
,
nickname
,
name
,
surname
,
url_img
,
gender
,
lang
,
attributes
)
VALUES
(
NEW
.
id_stu
,
NEW
.
nickname_stu
,
NEW
.
name_stu
,
NEW
.
surname_stu
,
NEW
.
url_img_stu
,
NEW
.
gender_stu
,
NEW
.
lang_stu
,
NEW
.
attributes_stu
);
INSERT
OR
REPLACE
INTO
supervisor
VALUES
(
NEW
.
id_sup
,
NEW
.
email_sup
,
NEW
.
pwd_sup
,
NEW
.
name_sup
,
NEW
.
surname_sup
,
NEW
.
url_img_sup
,
NEW
.
gender_sup
,
NEW
.
lang_sup
,
NEW
.
tts_engine_sup
);
INSERT
OR
REPLACE
INTO
student
(
id
,
nickname
,
name
,
surname
,
url_img
,
gender
,
lang
,
attributes
)
VALUES
(
NEW
.
id_stu
,
NEW
.
nickname_stu
,
NEW
.
name_stu
,
NEW
.
surname_stu
,
NEW
.
url_img_stu
,
NEW
.
gender_stu
,
NEW
.
lang_stu
,
NEW
.
attributes_stu
);
INSERT
OR
REPLACE
INTO
supervisor
VALUES
(
NEW
.
id_sup
,
NEW
.
email_sup
,
NEW
.
pwd_sup
,
NEW
.
name_sup
,
NEW
.
surname_sup
,
NEW
.
url_img_sup
,
NEW
.
gender_sup
,
NEW
.
lang_sup
,
NEW
.
tts_engine_sup
);
INSERT
OR
REPLACE
INTO
users
VALUES
(
NEW
.
id_stu
,
NEW
.
id_sup
);
END
;
--
CREATE
TRIGGER
trg_update_users_detail
INSTEAD
OF
UPDATE
ON
users_detail
FOR
EACH
ROW
...
...
@@ -252,4 +251,4 @@ BEGIN
INSERT
OR
REPLACE
INTO
picto
VALUES
(
NEW
.
id_picto
,
NEW
.
url
,
NEW
.
translation
);
INSERT
INTO
collection
VALUES
(
NEW
.
id_stu
,
NEW
.
id_picto
,
NEW
.
attributes
);
END
;
--
\ No newline at end of file
;
--
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