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
72e99377
authored
Feb 20, 2017
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issue #946 closed
parent
70bb2d89
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
44 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/RestapiWrapper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/PictoAction.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/RestapiWrapper.java
View file @
72e99377
...
@@ -215,7 +215,6 @@ public class RestapiWrapper {
...
@@ -215,7 +215,6 @@ public class RestapiWrapper {
}
}
}
}
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"POST-->"
+
surl
+
" "
+
request_method
+
" j"
+
json_params
+
" param"
+
sparams
);
//Send request
//Send request
DataOutputStream
wr
=
new
DataOutputStream
(
DataOutputStream
wr
=
new
DataOutputStream
(
urlConnection
.
getOutputStream
());
urlConnection
.
getOutputStream
());
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/PictoAction.java
View file @
72e99377
...
@@ -2,9 +2,8 @@ package com.yottacode.pictogram.action;
...
@@ -2,9 +2,8 @@ package com.yottacode.pictogram.action;
import
android.util.Log
;
import
android.util.Log
;
import
com.yottacode.pictogram.net.websockets.Room
;
import
com.yottacode.pictogram.dao.Picto
;
import
com.yottacode.pictogram.dao.Picto
;
import
com.yottacode.pictogram.
tools.PCBcontext
;
import
com.yottacode.pictogram.
net.websockets.Room
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -50,9 +49,7 @@ public abstract class PictoAction extends Action {
...
@@ -50,9 +49,7 @@ public abstract class PictoAction extends Action {
public
JSONObject
get_json_picto
()
throws
JSONException
{
public
JSONObject
get_json_picto
()
throws
JSONException
{
final
String
param_id_json
=
"id"
;
final
String
param_id_json
=
"id"
;
final
String
param_picto
=
"picto"
;
final
String
param_picto
=
"picto"
;
final
String
param_expression
=
"expression"
;
final
String
param_expr_lang
=
"lang"
;
final
String
param_expr_text
=
"text"
;
final
String
param_attrs
=
"attributes"
;
final
String
param_attrs
=
"attributes"
;
final
String
param_picto_id
=
"id"
;
final
String
param_picto_id
=
"id"
;
final
String
param_picto_uri
=
"uri"
;
final
String
param_picto_uri
=
"uri"
;
...
@@ -61,11 +58,8 @@ public abstract class PictoAction extends Action {
...
@@ -61,11 +58,8 @@ public abstract class PictoAction extends Action {
.
put
(
param_picto_uri
,
picto
.
get_url
())
.
put
(
param_picto_uri
,
picto
.
get_url
())
.
put
(
param_picto_cat
,
picto
.
get_category
());
.
put
(
param_picto_cat
,
picto
.
get_category
());
JSONObject
attributes
=
new
JSONObject
(
picto
.
get_json_attrs
());
JSONObject
attributes
=
new
JSONObject
(
picto
.
get_json_attrs
());
JSONObject
expression
=
new
JSONObject
().
put
(
param_expr_lang
,
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_lang_stu
())
.
put
(
param_expr_text
,
picto
.
get_translation
());
JSONObject
subPicto
=
new
JSONObject
().
put
(
param_id_json
,
1470
)
JSONObject
subPicto
=
new
JSONObject
().
put
(
param_id_json
,
1470
)
.
put
(
param_picto
,
subsubPicto
)
.
put
(
param_picto
,
subsubPicto
)
.
put
(
param_expression
,
expression
)
.
put
(
param_attrs
,
attributes
);
.
put
(
param_attrs
,
attributes
);
return
subPicto
;
return
subPicto
;
}
}
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
View file @
72e99377
...
@@ -227,7 +227,6 @@ public class PCBDBHelper extends SQLiteOpenHelper {
...
@@ -227,7 +227,6 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @see com.yottacode.pictogram.dao.Picto
* @see com.yottacode.pictogram.dao.Picto
*/
*/
public
void
deletePicto
(
int
picto_id
)
{
public
void
deletePicto
(
int
picto_id
)
{
int
id_stu
=
this
.
getCurrentUser
().
get_id_stu
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
delete
(
"collection"
,
"id_stu=? AND id_picto=?"
,
db
.
delete
(
"collection"
,
"id_stu=? AND id_picto=?"
,
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
72e99377
...
@@ -70,8 +70,7 @@ public class Picto extends Img {
...
@@ -70,8 +70,7 @@ public class Picto extends Img {
private
JSONObject
attributes
;
private
JSONObject
attributes
;
private
String
translation
;
private
boolean
is_mirror
=
false
;
private
boolean
is_mirror
=
false
;
private
boolean
highlight_background
=
false
;
private
boolean
highlight_background
=
false
;
public
boolean
is_mirror
()
{
return
is_mirror
;}
public
boolean
is_mirror
()
{
return
is_mirror
;}
...
@@ -88,10 +87,9 @@ public class Picto extends Img {
...
@@ -88,10 +87,9 @@ public class Picto extends Img {
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
}
}
translation
=
new
String
(
p
.
get_translation
());
}
}
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
)
throws
JSONException
{
this
(
id
,
url
,
translation
,
new
JSONObject
()
this
(
id
,
url
,
new
JSONObject
()
.
put
(
JSON_ATTTRS
.
CATEGORY
,
cat
)
.
put
(
JSON_ATTTRS
.
CATEGORY
,
cat
)
.
put
(
JSON_ATTTRS
.
COLUMN
,
column
)
.
put
(
JSON_ATTTRS
.
COLUMN
,
column
)
.
put
(
JSON_ATTTRS
.
ROW
,
row
)
.
put
(
JSON_ATTTRS
.
ROW
,
row
)
...
@@ -99,16 +97,16 @@ public class Picto extends Img {
...
@@ -99,16 +97,16 @@ public class Picto extends Img {
.
put
(
JSON_ATTTRS
.
FREE_COLUMN
,
freeColumn
)
.
put
(
JSON_ATTTRS
.
FREE_COLUMN
,
freeColumn
)
.
put
(
JSON_ATTTRS
.
STATUS
,
JSON_ATTTR_STATUS_VALUES
.
ENABLED
)
.
put
(
JSON_ATTTRS
.
STATUS
,
JSON_ATTTR_STATUS_VALUES
.
ENABLED
)
.
put
(
JSON_ATTTRS
.
LEGEND
,
JSON_ATTTR_LEGEND_VALUES
.
NONE
)
.
put
(
JSON_ATTTRS
.
LEGEND
,
JSON_ATTTR_LEGEND_VALUES
.
NONE
)
.
put
(
JSON_ATTTRS
.
STUPICTO_ID
,
stupicto_id
));
.
put
(
JSON_ATTTRS
.
STUPICTO_ID
,
stupicto_id
)
.
put
(
JSON_ATTTRS
.
EXPRESSION
,
translation
));
}
}
public
Picto
(
int
id
,
String
url
,
String
translation
,
String
attributes
)
throws
JSONException
{
public
Picto
(
int
id
,
String
url
,
String
translation
,
String
attributes
)
throws
JSONException
{
this
(
id
,
url
,
translation
,
new
JSONObject
(
attributes
));
this
(
id
,
url
,
new
JSONObject
(
attributes
).
put
(
JSON_ATTTRS
.
EXPRESSION
,
translation
));
}
}
public
Picto
(
int
id
,
String
url
,
String
translation
,
JSONObject
attributes
)
{
public
Picto
(
int
id
,
String
url
,
JSONObject
attributes
)
{
super
(
id
,
url
,
Img
.
VOCABULARY
);
super
(
id
,
url
,
Img
.
VOCABULARY
);;
this
.
translation
=
translation
;
this
.
attributes
=
attributes
;
this
.
attributes
=
attributes
;
try
{
try
{
if
(
this
.
attributes
.
get
(
JSON_ATTTRS
.
CATEGORY
)==
null
)
if
(
this
.
attributes
.
get
(
JSON_ATTTRS
.
CATEGORY
)==
null
)
...
@@ -131,18 +129,6 @@ public class Picto extends Img {
...
@@ -131,18 +129,6 @@ public class Picto extends Img {
*/
*/
public
String
get_url
()
{
return
this
.
url
;}
public
String
get_url
()
{
return
this
.
url
;}
/**
*
* @param newTranslation
*/
public
void
set_translation
(
String
newTranslation
){
this
.
translation
=
newTranslation
;
try
{
this
.
attributes
.
put
(
JSON_ATTTRS
.
EXPRESSION
,
newTranslation
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
/**
/**
*
*
...
@@ -154,10 +140,10 @@ public class Picto extends Img {
...
@@ -154,10 +140,10 @@ public class Picto extends Img {
translation
=
this
.
attributes
.
has
(
JSON_ATTTRS
.
EXPRESSION
)
&&
translation
=
this
.
attributes
.
has
(
JSON_ATTTRS
.
EXPRESSION
)
&&
this
.
attributes
.
getString
(
JSON_ATTTRS
.
EXPRESSION
)!=
null
&&
!
this
.
attributes
.
getString
(
JSON_ATTTRS
.
EXPRESSION
).
equals
(
"null"
)
this
.
attributes
.
getString
(
JSON_ATTTRS
.
EXPRESSION
)!=
null
&&
!
this
.
attributes
.
getString
(
JSON_ATTTRS
.
EXPRESSION
).
equals
(
"null"
)
?
this
.
attributes
.
getString
(
JSON_ATTTRS
.
EXPRESSION
)
?
this
.
attributes
.
getString
(
JSON_ATTTRS
.
EXPRESSION
)
:
this
.
translation
;
:
""
;
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
translation
=
this
.
translation
;
translation
=
""
;
}
}
return
translation
;
return
translation
;
}
}
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
View file @
72e99377
...
@@ -91,8 +91,14 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -91,8 +91,14 @@ public class Vocabulary implements Iterable<Picto> {
String
uri
=
args
.
getJSONObject
(
"picto"
).
getString
(
"uri"
);
String
uri
=
args
.
getJSONObject
(
"picto"
).
getString
(
"uri"
);
JSONObject
attrs_picto
=
args
.
getJSONObject
(
"attributes"
);
JSONObject
attrs_picto
=
args
.
getJSONObject
(
"attributes"
);
attrs_picto
.
put
(
Picto
.
JSON_ATTTRS
.
STUPICTO_ID
,
args
.
getInt
(
"id"
));
attrs_picto
.
put
(
Picto
.
JSON_ATTTRS
.
STUPICTO_ID
,
args
.
getInt
(
"id"
));
String
text
=
attrs_picto
.
getString
(
"expression"
);
Picto
newPicto
=
new
Picto
(
picto_id
,
uri
,
attrs_picto
);
addPicto
(
new
Picto
(
picto_id
,
uri
,
text
,
attrs_picto
),
ImgDownloader
.
tsource
.
remote
);
Picto
prev_picto
=
find_picto
(
newPicto
.
get_category
(),
newPicto
.
get_row
(),
newPicto
.
get_column
());
if
(
prev_picto
!=
null
)
{
Log
.
i
(
LOG_TAG
,
"Pictogram "
+
prev_picto
.
get_translation
()+
":"
+
prev_picto
.
get_id
()+
" to be replaced by "
+
newPicto
.
get_translation
()+
":"
+
newPicto
.
get_id
());
removePicto
(
prev_picto
.
get_category
(),
prev_picto
.
get_id
());
}
if
(
find_picto_index
(
newPicto
.
get_category
(),
newPicto
.
get_id
())==-
1
)
addPicto
(
newPicto
,
ImgDownloader
.
tsource
.
remote
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
e
.
getClass
().
getCanonicalName
()
+
"--"
+
e
);
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
e
.
getClass
().
getCanonicalName
()
+
"--"
+
e
);
...
@@ -171,12 +177,10 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -171,12 +177,10 @@ public class Vocabulary implements Iterable<Picto> {
final
String
jid
=
"id"
;
final
String
jid
=
"id"
;
final
String
juri
=
"uri"
;
final
String
juri
=
"uri"
;
final
String
jattributes
=
"attributes"
;
final
String
jattributes
=
"attributes"
;
final
String
jexpression
=
"expression"
;
Picto
[]
pictos
=
new
Picto
[
result
.
length
()];
Picto
[]
pictos
=
new
Picto
[
result
.
length
()];
JSONObject
picto
,
attributes
;
JSONObject
picto
,
attributes
;
String
expression
;
JSONObject
stupicto
=
null
;
JSONObject
stupicto
=
null
;
try
{
try
{
for
(
int
i
=
0
;
i
<
result
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
result
.
length
();
i
++)
{
...
@@ -184,10 +188,8 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -184,10 +188,8 @@ public class Vocabulary implements Iterable<Picto> {
picto
=
stupicto
.
getJSONObject
(
jpicto
);
picto
=
stupicto
.
getJSONObject
(
jpicto
);
attributes
=
stupicto
.
getJSONObject
(
jattributes
);
attributes
=
stupicto
.
getJSONObject
(
jattributes
);
attributes
.
put
(
Picto
.
JSON_ATTTRS
.
STUPICTO_ID
,
stupicto
.
get
(
jid
));
attributes
.
put
(
Picto
.
JSON_ATTTRS
.
STUPICTO_ID
,
stupicto
.
get
(
jid
));
expression
=
attributes
.
getString
(
jexpression
);
pictos
[
i
]
=
new
Picto
(
picto
.
getInt
(
jid
),
pictos
[
i
]
=
new
Picto
(
picto
.
getInt
(
jid
),
picto
.
getString
(
juri
),
picto
.
getString
(
juri
),
expression
,
attributes
);
attributes
);
}
}
synchronizeImgs
(
pictos
);
synchronizeImgs
(
pictos
);
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
View file @
72e99377
...
@@ -317,11 +317,11 @@ public class PictoUploader {
...
@@ -317,11 +317,11 @@ public class PictoUploader {
GUITools
.
show_alert
(
PCBcontext
.
getActivityContext
(),
errmsg
,
PictoUploader
.
this
.
picto
.
get_translation
());
GUITools
.
show_alert
(
PCBcontext
.
getActivityContext
(),
errmsg
,
PictoUploader
.
this
.
picto
.
get_translation
());
}
}
if
(
elements_uploaded
==
elements_to_be_uploaded
)
{
if
(
elements_uploaded
==
elements_to_be_uploaded
)
{
PCBcontext
.
get
Pcbdb
().
deletePicto
(
local_img_id
);
PCBcontext
.
get
Vocabulary
().
removePicto
(
picto
.
get_category
(),
local_img_id
);
PictoUploader
.
this
.
picto
.
delete_bitmap
(
PCBcontext
.
getContext
());
PictoUploader
.
this
.
picto
.
delete_bitmap
(
PCBcontext
.
getContext
());
PCBcontext
.
getVocabulary
().
addPicto
(
picto
);
PCBcontext
.
getVocabulary
().
addPicto
(
picto
);
PCBcontext
.
getRoom
().
emit
(
new
VocabularyAction
(
VocabularyAction
.
ADD
,
PictoUploader
.
this
.
picto
));
PCBcontext
.
getRoom
().
emit
(
new
VocabularyAction
(
VocabularyAction
.
ADD
,
PictoUploader
.
this
.
picto
));
GUITools
.
show_alert
(
PCBcontext
.
getContext
(),
R
.
string
.
upload_ok
,
PictoUploader
.
this
.
picto
.
get_translation
());
GUITools
.
show_alert
(
PCBcontext
.
get
Activity
Context
(),
R
.
string
.
upload_ok
,
PictoUploader
.
this
.
picto
.
get_translation
());
}
}
}
}
};
};
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
View file @
72e99377
...
@@ -69,6 +69,7 @@ import java.io.ByteArrayOutputStream;
...
@@ -69,6 +69,7 @@ import java.io.ByteArrayOutputStream;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
...
@@ -505,8 +506,9 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
...
@@ -505,8 +506,9 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
// This is to show the pictos ordered in the 2D Array that represents the panel
// This is to show the pictos ordered in the 2D Array that represents the panel
Picto
[][]
mp
=
new
Picto
[
maxRows
][
maxColumns
];
Picto
[][]
mp
=
new
Picto
[
maxRows
][
maxColumns
];
Iterator
<
Picto
>
pictos
=
list
.
iterator
();
for
(
Picto
p
:
list
)
{
while
(
pictos
.
hasNext
())
{
Picto
p
=
pictos
.
next
();
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
has_categories
())
{
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
has_categories
())
{
if
(
p
.
get_column
()
!=
-
1
&&
p
.
get_row
()
!=
-
1
if
(
p
.
get_column
()
!=
-
1
&&
p
.
get_row
()
!=
-
1
&&
p
.
get_column
()
<
maxRows
&&
p
.
get_row
()
<
maxColumns
)
{
&&
p
.
get_column
()
<
maxRows
&&
p
.
get_row
()
<
maxColumns
)
{
...
...
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