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
0c68ed09
authored
Feb 15, 2017
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
trabajando en modificar imagen desde el pcb
parent
4378e15d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
69 additions
and
199 deletions
android/Pictogram/commonlibrary/build.gradle
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/RestapiWrapper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Device.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/commonlibrary/src/main/java/com/yottacode/pictogram/net/websockets/VocabularyTalk.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoItemViewGenerator.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoMenu.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
android/Pictogram/commonlibrary/build.gradle
View file @
0c68ed09
...
@@ -10,7 +10,7 @@ android {
...
@@ -10,7 +10,7 @@ android {
versionCode
1
versionCode
1
versionName
"1.0"
versionName
"1.0"
resValue
"string"
,
"db_name"
,
"PCB.db"
resValue
"string"
,
"db_name"
,
"PCB.db"
resValue
"integer"
,
"db_version"
,
"
3
"
resValue
"integer"
,
"db_version"
,
"
4
"
resValue
"string"
,
"app_version"
,
"0.1"
resValue
"string"
,
"app_version"
,
"0.1"
resValue
"string"
,
"core_vocabulary"
,
"core_vocabulary"
resValue
"string"
,
"core_vocabulary"
,
"core_vocabulary"
resValue
"string"
,
"apk"
,
"to_be_set_in_subproject"
resValue
"string"
,
"apk"
,
"to_be_set_in_subproject"
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/RestapiWrapper.java
View file @
0c68ed09
...
@@ -215,7 +215,7 @@ public class RestapiWrapper {
...
@@ -215,7 +215,7 @@ 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/dao/Device.java
View file @
0c68ed09
...
@@ -54,7 +54,7 @@ public class Device extends SQLiteOpenHelper {
...
@@ -54,7 +54,7 @@ public class Device extends SQLiteOpenHelper {
*/
*/
public
Device
(
Context
context
,
CursorFactory
factory
,
int
version
)
{
public
Device
(
Context
context
,
CursorFactory
factory
,
int
version
)
{
super
(
context
,
DeviceHelper
.
getDBName
(
context
),
factory
,
DeviceHelper
.
getDBVersion
(
context
)
);
super
(
context
,
DeviceHelper
.
getDBName
(
context
),
factory
,
version
);
if
(
DeviceHelper
.
force_create
(
context
))
{
if
(
DeviceHelper
.
force_create
(
context
))
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Forcing create new Database "
+
DeviceHelper
.
getDBName
(
context
)+
" v."
+
DeviceHelper
.
getDBVersion
(
context
));
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Forcing create new Database "
+
DeviceHelper
.
getDBName
(
context
)+
" v."
+
DeviceHelper
.
getDBVersion
(
context
));
context
.
deleteDatabase
(
DeviceHelper
.
getDBName
(
context
));
context
.
deleteDatabase
(
DeviceHelper
.
getDBName
(
context
));
...
@@ -354,11 +354,10 @@ public class Device extends SQLiteOpenHelper {
...
@@ -354,11 +354,10 @@ public class Device extends SQLiteOpenHelper {
Cursor
cursor
=
db
.
query
(
"picto"
,
new
String
[]{
"(SELECT MIN(id) FROM picto) AS MIN"
},
null
,
null
,
null
,
null
,
null
,
"1"
);
Cursor
cursor
=
db
.
query
(
"picto"
,
new
String
[]{
"(SELECT MIN(id) FROM picto) AS MIN"
},
null
,
null
,
null
,
null
,
null
,
"1"
);
cursor
.
moveToFirst
();
cursor
.
moveToFirst
();
next_key
=
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"MIN"
))-
1
;
next_key
=
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"MIN"
))-
1
;
if
(
next_key
>=
0
)
next_key
=-
1
;
cursor
.
close
();
cursor
.
close
();
db
.
close
();
db
.
close
();
return
next_key
;
return
next_key
>=
0
?
-
1
:
next_key
;
}
}
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
View file @
0c68ed09
...
@@ -155,7 +155,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
...
@@ -155,7 +155,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
cursor
.
moveToFirst
();
cursor
.
moveToFirst
();
if
(
cursor
.
getCount
()>
0
)
do
{
if
(
cursor
.
getCount
()>
0
)
do
{
Picto
picto
=
new
Picto
(
cursor
.
getInt
(
1
),
cursor
.
getString
(
2
),
cursor
.
getString
(
3
),
cursor
.
getString
(
4
));
Picto
picto
=
new
Picto
(
cursor
.
getInt
(
1
),
cursor
.
getString
(
2
),
cursor
.
getString
(
3
),
cursor
.
getString
(
4
));
vocabulary
.
loa
dPicto
(
picto
);
vocabulary
.
ad
dPicto
(
picto
);
}
while
(
cursor
.
moveToNext
());
}
while
(
cursor
.
moveToNext
());
cursor
.
close
();
cursor
.
close
();
db
.
close
();
db
.
close
();
...
@@ -204,7 +204,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
...
@@ -204,7 +204,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @param picto added to the Student collection
* @param picto added to the Student collection
* @see com.yottacode.pictogram.dao.Picto
* @see com.yottacode.pictogram.dao.Picto
*/
*/
public
void
add
Picto
(
Picto
picto
)
{
public
void
save
Picto
(
Picto
picto
)
{
int
id_stu
=
this
.
getCurrentUser
().
get_id_stu
();
int
id_stu
=
this
.
getCurrentUser
().
get_id_stu
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
ContentValues
values
=
new
ContentValues
(
6
);
ContentValues
values
=
new
ContentValues
(
6
);
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
0c68ed09
...
@@ -2,8 +2,6 @@ package com.yottacode.pictogram.dao;
...
@@ -2,8 +2,6 @@ package com.yottacode.pictogram.dao;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
android.util.Log
;
import
android.util.Log
;
import
com.yottacode.pictogram.action.VocabularyAction
;
import
com.yottacode.pictogram.action.VocabularyAction
;
...
@@ -14,8 +12,6 @@ import com.yottacode.pictogram.tools.PCBcontext;
...
@@ -14,8 +12,6 @@ import com.yottacode.pictogram.tools.PCBcontext;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.io.Serializable
;
/**
/**
* A object which represents a pictogram
* A object which represents a pictogram
...
@@ -25,7 +21,22 @@ import java.io.Serializable;
...
@@ -25,7 +21,22 @@ import java.io.Serializable;
*/
*/
public
class
Picto
extends
Img
{
public
class
Picto
extends
Img
{
private
static
final
String
LOG_TAG
=
Img
.
class
.
getName
();
public
static
final
int
STUPICTO_NULL
=
-
1
;
public
int
get_stupicto_id
()
{
int
stupicto_id
;
try
{
stupicto_id
=
this
.
attributes
.
getInt
(
JSON_ATTTRS
.
STUPICTO_ID
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
stupicto_id
=
STUPICTO_NULL
;
}
return
stupicto_id
;
}
public
final
static
class
JSON_ATTTRS
{
public
final
static
class
JSON_ATTTRS
{
public
static
String
STUPICTO_ID
=
"id"
;
public
static
String
CATEGORY
=
"id_cat"
;
public
static
String
CATEGORY
=
"id_cat"
;
public
static
String
COLUMN
=
"coord_x"
;
public
static
String
COLUMN
=
"coord_x"
;
public
static
String
ROW
=
"coord_y"
;
public
static
String
ROW
=
"coord_y"
;
...
@@ -75,11 +86,11 @@ public class Picto extends Img {
...
@@ -75,11 +86,11 @@ public class Picto extends Img {
try
{
try
{
this
.
attributes
=
new
JSONObject
(
p
.
attributes
.
toString
());
this
.
attributes
=
new
JSONObject
(
p
.
attributes
.
toString
());
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
}
}
translation
=
new
String
(
p
.
get_translation
());
translation
=
new
String
(
p
.
get_translation
());
}
}
public
Picto
(
int
id
,
String
url
,
String
translation
,
int
cat
,
int
row
,
int
column
,
int
freeRow
,
int
freeColumn
)
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
,
translation
,
new
JSONObject
()
.
put
(
JSON_ATTTRS
.
CATEGORY
,
cat
)
.
put
(
JSON_ATTTRS
.
CATEGORY
,
cat
)
.
put
(
JSON_ATTTRS
.
COLUMN
,
column
)
.
put
(
JSON_ATTTRS
.
COLUMN
,
column
)
...
@@ -87,7 +98,8 @@ public class Picto extends Img {
...
@@ -87,7 +98,8 @@ public class Picto extends Img {
.
put
(
JSON_ATTTRS
.
FREE_ROW
,
freeRow
)
.
put
(
JSON_ATTTRS
.
FREE_ROW
,
freeRow
)
.
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
));
}
}
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
,
translation
,
new
JSONObject
(
attributes
));
...
@@ -102,7 +114,7 @@ public class Picto extends Img {
...
@@ -102,7 +114,7 @@ public class Picto extends Img {
if
(
this
.
attributes
.
get
(
JSON_ATTTRS
.
CATEGORY
)==
null
)
if
(
this
.
attributes
.
get
(
JSON_ATTTRS
.
CATEGORY
)==
null
)
this
.
attributes
.
put
(
JSON_ATTTRS
.
CATEGORY
,
Picto
.
NO_CATEGORY
);
this
.
attributes
.
put
(
JSON_ATTTRS
.
CATEGORY
,
Picto
.
NO_CATEGORY
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
Log
.
e
(
this
.
getClass
().
getName
()
,
e
.
toString
());
Log
.
e
(
LOG_TAG
,
e
.
toString
());
}
}
}
}
...
@@ -282,6 +294,7 @@ public class Picto extends Img {
...
@@ -282,6 +294,7 @@ public class Picto extends Img {
legend
=
this
.
attributes
.
getString
(
JSON_ATTTRS
.
LEGEND
);
legend
=
this
.
attributes
.
getString
(
JSON_ATTTRS
.
LEGEND
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
legend
=
JSON_ATTTR_LEGEND_VALUES
.
NONE
;
// By default
legend
=
JSON_ATTTR_LEGEND_VALUES
.
NONE
;
// By default
Log
.
e
(
LOG_TAG
,
" Error getting legend:"
+
e
.
getMessage
());
}
}
return
legend
.
equalsIgnoreCase
(
"null"
)
?
JSON_ATTTR_LEGEND_VALUES
.
NONE
:
legend
;
return
legend
.
equalsIgnoreCase
(
"null"
)
?
JSON_ATTTR_LEGEND_VALUES
.
NONE
:
legend
;
}
}
...
@@ -363,36 +376,14 @@ public class Picto extends Img {
...
@@ -363,36 +376,14 @@ public class Picto extends Img {
return
"("
+
get_id
()
+
") - ["
+
get_row
()
+
","
+
get_column
()+
"]"
+
get_translation
()
+
"(Cat: "
+
get_category
()
+
") - "
+
get_url
()
+
" --- "
+
get_json_attrs
();
return
"("
+
get_id
()
+
") - ["
+
get_row
()
+
","
+
get_column
()+
"]"
+
get_translation
()
+
"(Cat: "
+
get_category
()
+
") - "
+
get_url
()
+
" --- "
+
get_json_attrs
();
}
}
/**
* modify locally the status of the picto
* @return true if current status is enabled. False in other case.
*/
/*public boolean alter_status() {
String status=is_enabled() ? JSON_ATTTR_STATUS_VALUES.DISABLED
: is_disabled() ? JSON_ATTTR_STATUS_VALUES.INVISIBLE
: JSON_ATTTR_STATUS_VALUES.ENABLED;
Log.i(this.getClass().getCanonicalName(),"Picto id. "+get_id()+" status enabled/disabled modified to "+is_enabled());
try {
this.attributes.put(JSON_ATTTRS.STATUS, status);
set_local_status(true);
if (!is_local()) {
new PictoUploader(this).uploadState();
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS, this));
}
} catch (JSONException e) {
e.printStackTrace();
Log.e(this.getClass().getCanonicalName(),e.getMessage());
}
return is_enabled();
}
*/
/**
/**
* modify locally the status of the picto
* modify locally the status of the picto
* @param status the status that u press on the menu
* @param status the status that u press on the menu
* @return true if current status is enabled. False in other case.
* @return true if current status is enabled. False in other case.
*/
*/
public
boolean
alter_status
(
String
status
)
{
public
boolean
alter_status
(
String
status
)
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
"Picto id. "
+
get_id
()+
" status enabled/disabled modified to "
+
is_enabled
());
Log
.
i
(
LOG_TAG
,
"Picto id. "
+
get_id
()+
" status enabled/disabled modified to "
+
is_enabled
());
try
{
try
{
this
.
attributes
.
put
(
JSON_ATTTRS
.
STATUS
,
status
);
this
.
attributes
.
put
(
JSON_ATTTRS
.
STATUS
,
status
);
set_local_status
(
true
);
set_local_status
(
true
);
...
@@ -402,7 +393,7 @@ public class Picto extends Img {
...
@@ -402,7 +393,7 @@ public class Picto extends Img {
}
}
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
}
}
return
is_enabled
();
return
is_enabled
();
}
}
...
@@ -425,7 +416,7 @@ public class Picto extends Img {
...
@@ -425,7 +416,7 @@ public class Picto extends Img {
PCBcontext
.
getPcbdb
().
modifyPicto
(
this
.
get_id
(),
this
.
get_json_attrs
());
PCBcontext
.
getPcbdb
().
modifyPicto
(
this
.
get_id
(),
this
.
get_json_attrs
());
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
}
}
else
{
else
{
...
@@ -433,4 +424,5 @@ public class Picto extends Img {
...
@@ -433,4 +424,5 @@ public class Picto extends Img {
PCBcontext
.
getPcbdb
().
modifyPicto
(
this
.
get_id
(),
this
.
get_json_attrs
());
PCBcontext
.
getPcbdb
().
modifyPicto
(
this
.
get_id
(),
this
.
get_json_attrs
());
}
}
}
}
}
}
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
View file @
0c68ed09
...
@@ -90,6 +90,7 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -90,6 +90,7 @@ public class Vocabulary implements Iterable<Picto> {
try
{
try
{
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"
));
String
text
=
attrs_picto
.
getString
(
"expression"
);
String
text
=
attrs_picto
.
getString
(
"expression"
);
addPicto
(
new
Picto
(
picto_id
,
uri
,
text
,
attrs_picto
),
ImgDownloader
.
tsource
.
remote
);
addPicto
(
new
Picto
(
picto_id
,
uri
,
text
,
attrs_picto
),
ImgDownloader
.
tsource
.
remote
);
...
@@ -135,7 +136,7 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -135,7 +136,7 @@ public class Vocabulary implements Iterable<Picto> {
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Picto status modified while offline. Picto translation: '"
+
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Picto status modified while offline. Picto translation: '"
+
picto
.
get_translation
()
+
"', id:"
+
picto
.
get_id
()
+
" Local status?"
+
picto
.
local_status
());
picto
.
get_translation
()
+
"', id:"
+
picto
.
get_id
()
+
" Local status?"
+
picto
.
local_status
());
}
}
if
(
picto
.
is_local
())
//id<0 iif it is a local id
if
(
picto
.
is_local
())
try
{
try
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Picto added while offline. Picto translation: '"
+
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Picto added while offline. Picto translation: '"
+
picto
.
get_translation
()
+
"', id:"
+
picto
.
get_id
()
+
" Local status?"
+
picto
.
local_status
());
picto
.
get_translation
()
+
"', id:"
+
picto
.
get_id
()
+
" Local status?"
+
picto
.
local_status
());
...
@@ -172,17 +173,18 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -172,17 +173,18 @@ public class Vocabulary implements Iterable<Picto> {
final
String
juri
=
"uri"
;
final
String
juri
=
"uri"
;
final
String
jattributes
=
"attributes"
;
final
String
jattributes
=
"attributes"
;
final
String
jexpression
=
"expression"
;
final
String
jexpression
=
"expression"
;
final
String
jexpression_text
=
"text"
;
Picto
[]
pictos
=
new
Picto
[
result
.
length
()];
Picto
[]
pictos
=
new
Picto
[
result
.
length
()];
JSONObject
picto
=
null
,
attributes
=
null
;
JSONObject
picto
,
attributes
;
String
expression
;
String
expression
;
JSONObject
oj
picto
=
null
;
JSONObject
stu
picto
=
null
;
try
{
try
{
for
(
int
i
=
0
;
i
<
result
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
result
.
length
();
i
++)
{
ojpicto
=
result
.
getJSONObject
(
i
);
stupicto
=
result
.
getJSONObject
(
i
);
picto
=
ojpicto
.
getJSONObject
(
jpicto
);
picto
=
stupicto
.
getJSONObject
(
jpicto
);
attributes
=
ojpicto
.
getJSONObject
(
jattributes
);
attributes
=
stupicto
.
getJSONObject
(
jattributes
);
attributes
.
put
(
Picto
.
JSON_ATTTRS
.
STUPICTO_ID
,
stupicto
.
get
(
jid
));
expression
=
attributes
.
getString
(
jexpression
);
expression
=
attributes
.
getString
(
jexpression
);
pictos
[
i
]
=
new
Picto
(
picto
.
getInt
(
jid
),
pictos
[
i
]
=
new
Picto
(
picto
.
getInt
(
jid
),
picto
.
getString
(
juri
),
picto
.
getString
(
juri
),
...
@@ -197,7 +199,7 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -197,7 +199,7 @@ public class Vocabulary implements Iterable<Picto> {
StackTraceElement
traces
[]
=
e
.
getStackTrace
();
StackTraceElement
traces
[]
=
e
.
getStackTrace
();
for
(
StackTraceElement
s:
traces
)
for
(
StackTraceElement
s:
traces
)
Log
.
e
(
s
.
getClassName
()+
"."
+
s
.
getFileName
()+
"."
+
s
.
getLineNumber
(),
s
.
toString
());
Log
.
e
(
s
.
getClassName
()+
"."
+
s
.
getFileName
()+
"."
+
s
.
getLineNumber
(),
s
.
toString
());
Log
.
e
(
this
.
getClass
().
getName
(),
" Picto JSON error from server: "
+
oj
picto
.
toString
());
Log
.
e
(
this
.
getClass
().
getName
(),
" Picto JSON error from server: "
+
stu
picto
.
toString
());
this
.
error
(
new
RestapiWrapper
.
HTTPException
(
"JSON Error:"
+
e
.
getMessage
(),-
1
));
this
.
error
(
new
RestapiWrapper
.
HTTPException
(
"JSON Error:"
+
e
.
getMessage
(),-
1
));
}
}
}
}
...
@@ -264,9 +266,9 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -264,9 +266,9 @@ public class Vocabulary implements Iterable<Picto> {
ImgDownloader
downloader
=
new
ImgDownloader
(
PCBcontext
.
getContext
(),
imgListener
,
source
);
ImgDownloader
downloader
=
new
ImgDownloader
(
PCBcontext
.
getContext
(),
imgListener
,
source
);
downloader
.
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
,
imgs
);
downloader
.
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
,
imgs
);
loa
dPicto
(
pic
);
ad
dPicto
(
pic
);
PCBcontext
.
getPcbdb
().
add
Picto
(
pic
);
PCBcontext
.
getPcbdb
().
save
Picto
(
pic
);
}
}
public
void
setImgDownloaderListener
(
ImgDownloader
.
iImgDownloaderListener
listener
)
{
public
void
setImgDownloaderListener
(
ImgDownloader
.
iImgDownloaderListener
listener
)
{
...
@@ -289,6 +291,15 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -289,6 +291,15 @@ public class Vocabulary implements Iterable<Picto> {
return
index
;
return
index
;
}
}
private
Picto
find_picto
(
int
pic_cat
,
int
row
,
int
column
)
{
LinkedList
<
Picto
>
pictos_cat
=
this
.
pictos
.
get
(
pic_cat
);
Picto
picto
=
null
;
for
(
int
i
=
0
;
i
<
pictos_cat
.
size
()
&&
picto
==
null
;
i
++)
if
(
pictos_cat
.
get
(
i
).
get_column
()==
column
&&
pictos_cat
.
get
(
i
).
get_row
()==
row
)
picto
=
pictos_cat
.
get
(
i
);
return
picto
;
}
public
Picto
get_picto
(
int
pic_cat
,
int
pic_id
)
{
public
Picto
get_picto
(
int
pic_cat
,
int
pic_id
)
{
Picto
picto
=
null
;
Picto
picto
=
null
;
LinkedList
<
Picto
>
pictos_cat
=
this
.
pictos
.
get
(
pic_cat
);
LinkedList
<
Picto
>
pictos_cat
=
this
.
pictos
.
get
(
pic_cat
);
...
@@ -335,8 +346,7 @@ public class Vocabulary implements Iterable<Picto> {
...
@@ -335,8 +346,7 @@ public class Vocabulary implements Iterable<Picto> {
* @param picto
* @param picto
* @seealso com.yottacode.pictogram.dao.PCBDBHelper.getStudentVocabulary
* @seealso com.yottacode.pictogram.dao.PCBDBHelper.getStudentVocabulary
*/
*/
public
void
loadPicto
(
Picto
picto
)
{
public
void
addPicto
(
Picto
picto
)
{
Log
.
i
(
LOG_TAG
,
"load picto "
+
picto
.
get_translation
());
LinkedList
<
Picto
>
pictos_cat
;
LinkedList
<
Picto
>
pictos_cat
;
if
(
this
.
pictos
.
containsKey
(
picto
.
get_category
()))
if
(
this
.
pictos
.
containsKey
(
picto
.
get_category
()))
pictos_cat
=
pictos
.
get
(
picto
.
get_category
());
pictos_cat
=
pictos
.
get
(
picto
.
get_category
());
...
@@ -389,10 +399,19 @@ Log.i(LOG_TAG, "load picto "+picto.get_translation());
...
@@ -389,10 +399,19 @@ Log.i(LOG_TAG, "load picto "+picto.get_translation());
* It saves locally a new picto obtained from the PCB
* It saves locally a new picto obtained from the PCB
*/
*/
public
Picto
saveLocalPicto
(
String
url
,
String
exp
,
int
cat
,
int
coord_x
,
int
coord_y
,
int
free_category_coord_x
,
int
free_category_coord_y
,
final
iLocalPicto
listener
)
{
public
Picto
saveLocalPicto
(
String
url
,
String
exp
,
int
cat
,
int
coord_x
,
int
coord_y
,
int
free_category_coord_x
,
int
free_category_coord_y
,
final
iLocalPicto
listener
)
{
int
id
=
PCBcontext
.
getDevice
().
getNextLocalPictoID
();
Picto
prev_picto
=
find_picto
(
cat
,
coord_x
,
coord_y
);
//¿estamos reemplazanddo un picto que ya existe?
if
(
prev_picto
!=
null
)
{
//El picto ya existe
removePicto
(
prev_picto
.
get_category
(),
prev_picto
.
get_id
());
//borramos el picto local actual
Log
.
i
(
LOG_TAG
,
"Picto "
+
exp
+
" already exists. Previous local picto "
+
prev_picto
.
get_id
()+
" is deleted."
);
}
int
id
=
PCBcontext
.
getDevice
().
getNextLocalPictoID
();
final
Picto
picto
[]=
new
Picto
[
1
];
final
Picto
picto
[]=
new
Picto
[
1
];
try
{
try
{
picto
[
0
]
=
new
Picto
(
id
,
url
,
exp
,
cat
,
coord_x
,
coord_y
,
free_category_coord_x
,
free_category_coord_y
);
picto
[
0
]
=
new
Picto
(
id
,
url
,
exp
,
cat
,
coord_x
,
coord_y
,
free_category_coord_x
,
free_category_coord_y
,
prev_picto
!=
null
?
prev_picto
.
get_stupicto_id
()
:
Picto
.
STUPICTO_NULL
);
addPicto
(
picto
[
0
],
ImgDownloader
.
tsource
.
local
,
new
ImgDownloader
.
iImgDownloaderListener
()
{
addPicto
(
picto
[
0
],
ImgDownloader
.
tsource
.
local
,
new
ImgDownloader
.
iImgDownloaderListener
()
{
@Override
@Override
public
void
loadComplete
()
{
public
void
loadComplete
()
{
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
View file @
0c68ed09
This diff is collapsed.
Click to expand it.
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/websockets/VocabularyTalk.java
View file @
0c68ed09
...
@@ -45,6 +45,7 @@ public class VocabularyTalk implements Emitter.Listener {
...
@@ -45,6 +45,7 @@ public class VocabularyTalk implements Emitter.Listener {
Log
.
i
(
LOG_TAG
,
"raw Received message "
+
msg
.
toString
());
Log
.
i
(
LOG_TAG
,
"raw Received message "
+
msg
.
toString
());
String
action
=
msg
.
getString
(
param_action
).
toLowerCase
();
String
action
=
msg
.
getString
(
param_action
).
toLowerCase
();
JSONObject
stu_picto
=
msg
.
getJSONObject
(
param_attributes
).
getJSONObject
(
param_stu_picto
);
JSONObject
stu_picto
=
msg
.
getJSONObject
(
param_attributes
).
getJSONObject
(
param_stu_picto
);
int
stupicto_id
=
stu_picto
.
getInt
(
param_picto_id
);
JSONObject
attrs_stu_picto
=
stu_picto
.
optJSONObject
(
param_attributes
);
JSONObject
attrs_stu_picto
=
stu_picto
.
optJSONObject
(
param_attributes
);
JSONObject
picto_stupicto
=
stu_picto
.
optJSONObject
(
param_picto
);
JSONObject
picto_stupicto
=
stu_picto
.
optJSONObject
(
param_picto
);
int
picto_id
=
picto_stupicto
.
getInt
(
param_picto_id
);
int
picto_id
=
picto_stupicto
.
getInt
(
param_picto_id
);
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
View file @
0c68ed09
...
@@ -8,6 +8,7 @@ import com.yottacode.net.SSLDummyContext;
...
@@ -8,6 +8,7 @@ import com.yottacode.net.SSLDummyContext;
import
com.yottacode.pictogram.R
;
import
com.yottacode.pictogram.R
;
import
com.yottacode.pictogram.action.ActionLog
;
import
com.yottacode.pictogram.action.ActionLog
;
import
com.yottacode.pictogram.dao.Device
;
import
com.yottacode.pictogram.dao.Device
;
import
com.yottacode.pictogram.dao.DeviceHelper
;
import
com.yottacode.pictogram.dao.PCBDBHelper
;
import
com.yottacode.pictogram.dao.PCBDBHelper
;
import
com.yottacode.pictogram.dao.User
;
import
com.yottacode.pictogram.dao.User
;
import
com.yottacode.pictogram.grammar.Vocabulary
;
import
com.yottacode.pictogram.grammar.Vocabulary
;
...
@@ -38,7 +39,7 @@ public final class PCBcontext {
...
@@ -38,7 +39,7 @@ public final class PCBcontext {
if
(!
init
)
{
if
(!
init
)
{
init
=
true
;
init
=
true
;
context
=
c
;
context
=
c
;
device
=
new
Device
(
c
,
null
,
2
);
device
=
new
Device
(
c
,
null
,
DeviceHelper
.
getDBVersion
(
context
)
);
activityContext
=
null
;
activityContext
=
null
;
SSLDummyContext
.
init
(
context
.
getResources
().
getBoolean
(
R
.
bool
.
ssl_connect
));
SSLDummyContext
.
init
(
context
.
getResources
().
getBoolean
(
R
.
bool
.
ssl_connect
));
service
=
new
NetService
(
context
.
getResources
().
getInteger
(
R
.
integer
.
netservice_timing
),
listener
);
service
=
new
NetService
(
context
.
getResources
().
getInteger
(
R
.
integer
.
netservice_timing
),
listener
);
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoItemViewGenerator.java
View file @
0c68ed09
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
;
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.graphics.Paint
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
...
@@ -64,79 +60,6 @@ public class PictoItemViewGenerator {
...
@@ -64,79 +60,6 @@ public class PictoItemViewGenerator {
}
}
/**
* @param context
* @param bitmap Bitmap to add the legend and rescale
* @param picto
* @return the bitmap scaled and with the legend or without changes
*/
private
static
Bitmap
set_legend
(
Context
context
,
Bitmap
bitmap
,
Picto
picto
)
{
{
Paint
paint
=
new
Paint
(
Paint
.
ANTI_ALIAS_FLAG
);
int
width
=
bitmap
.
getWidth
();
//Ancho original
int
height
=
bitmap
.
getHeight
();
//Alto original
//String texto = format_legend(picto,MAX_LINE_LENGTH);
/*if(picto.get_legend().equals("normal")) { //Normal legend
android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
if (bitmapConfig == null) {
bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
}
bitmap = bitmap.copy(bitmapConfig, true);
Canvas canvas = new Canvas(bitmap);
Bitmap bm = Bitmap.createScaledBitmap(bitmap, width / 2, height / 2, false);
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); //Poner en blanco el bitmap original para dibujar encima
canvas.drawBitmap(bm, 25, 0, paint);
TextView textView = new TextView(context);
textView.layout(0, 50, 100, 100);
textView.setPadding(0, 0, 0, 0);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 13);
textView.setTextColor(Color.BLACK);
textView.setBackgroundColor(Color.WHITE);
textView.setWidth(100);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setMaxLines(4);
textView.setText(texto);
textView.setDrawingCacheEnabled(true);
canvas.drawBitmap(textView.getDrawingCache(), 0, 50, null);
}else{*/
//Only legend
android
.
graphics
.
Bitmap
.
Config
bitmapConfig
=
bitmap
.
getConfig
();
if
(
bitmapConfig
==
null
)
{
bitmapConfig
=
android
.
graphics
.
Bitmap
.
Config
.
ARGB_8888
;
}
bitmap
=
bitmap
.
copy
(
bitmapConfig
,
true
);
Canvas
canvas
=
new
Canvas
(
bitmap
);
paint
.
setColor
(
Color
.
WHITE
);
canvas
.
drawRect
(
0
,
0
,
100
,
100
,
paint
);
TextView
textView
=
new
TextView
(
context
);
textView
.
layout
(
0
,
0
,
100
,
100
);
textView
.
setPadding
(
0
,
0
,
0
,
0
);
textView
.
setTextSize
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_picto_size_big
()
?
13
:
11
);
textView
.
setTextColor
(
Color
.
rgb
(
0
,
0
,
0
));
textView
.
setWidth
(
100
);
textView
.
setGravity
(
Gravity
.
CENTER
);
textView
.
setMaxLines
(
3
);
//textView.setText(texto);
textView
.
setDrawingCacheEnabled
(
true
);
canvas
.
drawBitmap
(
textView
.
getDrawingCache
(),
0
,
25
,
null
);
}
//}
return
bitmap
;
}
public
static
View
getPictoView
(
Picto
picto
,
View
convertView
,
ViewGroup
parent
)
{
public
static
View
getPictoView
(
Picto
picto
,
View
convertView
,
ViewGroup
parent
)
{
return
getPictoView
(
picto
,
convertView
,
parent
,
false
);
return
getPictoView
(
picto
,
convertView
,
parent
,
false
);
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoMenu.java
View file @
0c68ed09
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
;
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.ArrayAdapter
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
android.widget.RelativeLayout
;
...
@@ -148,62 +140,6 @@ public class PictoMenu {
...
@@ -148,62 +140,6 @@ public class PictoMenu {
/**
* Función para la selección de una foto del carrete
*
* @param requestCode
* @param resultCode
* @param data
*/
/*public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
String selectedImagePath;
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
int row = activity.getIntent().getIntExtra(Picto.JSON_ATTTRS.ROW, -1);
int col = activity.getIntent().getIntExtra(Picto.JSON_ATTTRS.COLUMN, -1);
int freeRow = activity.getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_ROW, -1);
int freeColumn = activity.getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
Log.i(activity.getClass().getCanonicalName(), "0 Picto x y " + " " + row + " " + col);
activity.getIntent().removeExtra(Picto.JSON_ATTTRS.ROW);
activity.getIntent().removeExtra(Picto.JSON_ATTTRS.COLUMN);
activity.getIntent().removeExtra(Picto.JSON_ATTTRS.FREE_ROW);
activity.getIntent().removeExtra(Picto.JSON_ATTTRS.FREE_COLUMN);
//chooseTextAndSavePicto(selectedImagePath, row, col, freeRow, freeColumn);
}
}
}*/
/**
* Función para la selección de una foto del carrete
*
* @param uri
* @return
*/
static
public
String
getPath
(
Uri
uri
)
{
if
(
uri
==
null
)
{
return
null
;
}
// this will only work for images selected from gallery
String
[]
projection
=
{
MediaStore
.
Images
.
Media
.
DATA
};
Cursor
cursor
=
PCBcontext
.
getContext
().
getContentResolver
().
query
(
uri
,
projection
,
null
,
null
,
null
);
if
(
cursor
!=
null
)
{
int
column_index
=
cursor
.
getColumnIndexOrThrow
(
MediaStore
.
Images
.
Media
.
DATA
);
cursor
.
moveToFirst
();
return
cursor
.
getString
(
column_index
);
}
return
uri
.
getPath
();
}
/**Function for build a radial menu
/**Function for build a radial menu
...
@@ -243,7 +179,7 @@ public class PictoMenu {
...
@@ -243,7 +179,7 @@ public class PictoMenu {
PieMenu
.
addMenuEntry
(
new
UnlockPictoMenu
(
picto
));
PieMenu
.
addMenuEntry
(
new
UnlockPictoMenu
(
picto
));
PieMenu
.
addMenuEntry
(
new
DisablePictoMenu
(
picto
));
PieMenu
.
addMenuEntry
(
new
DisablePictoMenu
(
picto
));
PieMenu
.
addMenuEntry
(
new
SetInvisibleMenu
(
picto
));
PieMenu
.
addMenuEntry
(
new
SetInvisibleMenu
(
picto
));
PieMenu
.
addMenuEntry
(
new
EditMenu
(
picto
));
if
(!
picto
.
is_category
())
PieMenu
.
addMenuEntry
(
new
EditMenu
(
picto
));
ll
.
addView
(
PieMenu
);
ll
.
addView
(
PieMenu
);
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
View file @
0c68ed09
...
@@ -1093,7 +1093,6 @@ protected void showOnlyTape(boolean onlyTape) {
...
@@ -1093,7 +1093,6 @@ protected void showOnlyTape(boolean onlyTape) {
*/
*/
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
Log
.
e
(
LOG_TAG
,
"CTSA prec (onACR)"
+
requestCode
+
" "
+
resultCode
);
int
cat
=
getIntent
().
getIntExtra
(
"cat"
,
-
1
);
int
cat
=
getIntent
().
getIntExtra
(
"cat"
,
-
1
);
...
...
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