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
dbbe1c3b
authored
Jan 03, 2018
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Pictogram 1.6, Beta 2, issue
#421
parent
ffdb3acd
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
62 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/RestapiWrapper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/VocabularyIterator.java
android/Pictogram/communicator/build/intermediates/manifests/full/DevFlavor/debug/AndroidManifest.xml
android/Pictogram/supervisor/build.gradle
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/VocabularyManager.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoGridAdapter.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/VOCA.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/RestapiWrapper.java
View file @
dbbe1c3b
...
...
@@ -166,7 +166,12 @@ public class RestapiWrapper {
JSONresponse
=
new
JSONObject
(
"{ "
+
SERVER_RESULT
+
": "
+
response
+
(
responseCode
==
HttpURLConnection
.
HTTP_OK
?
"}"
:
", "
+
SERVER_ERROR
+
": "
+
responseCode
+
"}"
));
Log
.
i
(
LOG_TAG
,
"Server answer: "
+
JSONresponse
.
toString
());
int
i
=
0
;
String
sresponse
=
JSONresponse
.
toString
();
do
{
Log
.
i
(
LOG_TAG
,
"Server answer("
+
i
+
"):"
+
sresponse
.
substring
(
i
*
1000
,((
i
+
1
)*
1000
)>
sresponse
.
length
()
?
sresponse
.
length
()
:
(
i
+
1
)*
1000
));
i
++;
}
while
(
i
*
1000
<
sresponse
.
length
());
}
catch
(
JSONException
e
)
{
JSONresponse
=
null
;
Log
.
e
(
RestapiWrapper
.
class
.
getCanonicalName
(),
e
.
getMessage
());
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
View file @
dbbe1c3b
...
...
@@ -6,6 +6,7 @@ import android.database.Cursor;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteDatabase.CursorFactory
;
import
android.database.sqlite.SQLiteOpenHelper
;
import
android.graphics.Color
;
import
android.util.Log
;
import
com.yottacode.pictogram.action.Action
;
...
...
@@ -194,15 +195,13 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public
void
saveGridForStudent
(
JSONObject
grid
,
SQLiteDatabase
db
)
{
try
{
int
id_sup
=
-
1
;
if
(!
grid
.
get
(
"supervisor"
).
equals
(
null
)){
id_sup
=
grid
.
getInt
(
"supervisor"
);
}
int
id_sup
=
grid
.
optInt
(
"supervisor"
,-
1
);
String
sql_grid
=
"INSERT OR REPLACE INTO grid VALUES ("
+
grid
.
getInt
(
"id"
)
+
","
+
id_sup
+
",
'
"
+
grid
.
getInt
(
"student"
)
+
"
'
,'"
+
grid
.
getString
(
"name"
)
+
","
+
grid
.
getInt
(
"student"
)
+
",'"
+
grid
.
getString
(
"name"
)
+
"','"
+
grid
.
getBoolean
(
"active"
)
+
"','"
+
grid
.
getString
(
"color"
)
+
"')"
;
...
...
@@ -212,7 +211,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
(
);
Log
.
e
(
LOG_TAG
,
"Error saving grid "
+
grid
.
toString
()
);
}
}
...
...
@@ -220,15 +219,20 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* Get the pictos of a grid
*
* @param id_grid Id of the grid to recover
* @param id_stu Id of stu
*/
public
void
getGrid
(
int
id_grid
,
int
id_stu
)
{
public
int
getGridColor
(
int
id_grid
)
{
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
"SELECT * from collection_detail WHERE id_stu ="
+
id_stu
+
" AND id_grid = "
+
id_grid
,
null
);
Log
.
i
(
LOG_TAG
,
"Local recovering "
+
cursor
.
getCount
()
+
" pictos for student "
+
id_stu
+
" from local DB Scene:"
+
id_grid
);
String
[]
columns
={
"color"
};
Cursor
cursor
=
db
.
query
(
"grid"
,
columns
,
"id="
+
id_grid
,
null
,
null
,
null
,
null
,
null
);
String
query
=
"SELECT color from grid where id="
+
id_grid
;
cursor
=
db
.
rawQuery
(
query
,
null
);
cursor
.
moveToFirst
();
try
{
return
Color
.
parseColor
(
cursor
.
getString
(
0
));
}
catch
(
Exception
e
)
{
return
Color
.
TRANSPARENT
;
}
}
public
void
deleteVocabulary
(
SQLiteDatabase
db
)
{
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
View file @
dbbe1c3b
...
...
@@ -379,5 +379,4 @@ public class Vocabulary implements Iterable<Picto> {
return
vocabulary
;
}
}
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/VocabularyIterator.java
View file @
dbbe1c3b
package
com
.
yottacode
.
pictogram
.
grammar
;
import
android.util.Log
;
import
com.yottacode.pictogram.dao.Picto
;
import
java.util.Enumeration
;
...
...
@@ -45,10 +43,10 @@ public class VocabularyIterator implements Iterator<Picto> {
if
(
this
.
location
==
pictos
.
get
(
child_grid
).
size
())
{
this
.
location
=
0
;
this
.
child_grid
=
this
.
keys
.
nextElement
();
}
picto
=
pictos
.
get
(
child_grid
).
get
(
location
++);
return
picto
;
}
...
...
android/Pictogram/communicator/build/intermediates/manifests/full/DevFlavor/debug/AndroidManifest.xml
View file @
dbbe1c3b
...
...
@@ -35,6 +35,7 @@
android:icon=
"@drawable/ic_launcher"
android:label=
"@string/app_name"
android:supportsRtl=
"true"
android:testOnly=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
"com.yottacode.pictogram.tabletlibrary.gui.login.SplashScreenActivity"
...
...
android/Pictogram/supervisor/build.gradle
View file @
dbbe1c3b
...
...
@@ -2,6 +2,9 @@ apply plugin: 'com.android.application'
android
{
lintOptions
{
checkReleaseBuilds
false
}
compileSdkVersion
24
buildToolsVersion
'25.0.0'
...
...
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/VocabularyManager.java
View file @
dbbe1c3b
...
...
@@ -79,7 +79,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
// Grid showing pictos from a category (initially hidden)
GridView
pictoCategoryGridView
;
// Current picto category, if not null the corresponding category grid will be shown
private
Picto
currentCategory
;
private
int
currentGrid
;
// Element used for loading new pictos (while changing categories)
Vocabulary
vocabulary
;
...
...
@@ -123,7 +123,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
setContentView
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_picto_size_big
()
?
R
.
layout
.
vocabulary_manager_big
:
R
.
layout
.
vocabulary_manager
);
this
.
mainLayout
=
(
RelativeLayout
)
findViewById
(
R
.
id
.
pictogramLayout
);
this
.
current
Category
=
null
;
this
.
current
Grid
=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
;
if
(!
PCBcontext
.
is_user_logged
())
{
Log
.
i
(
LOG_TAG
,
"No user logged. Restarting app"
);
...
...
@@ -237,7 +237,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
this
.
generateAnimations
();
if
(
this
.
getCurrentCategory
()
!=
null
)
{
if
(
this
.
currentGrid
!=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
)
{
this
.
hidePictoMainGridView
();
}
else
{
this
.
showPictoMainGridView
();
...
...
@@ -415,7 +415,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
this
.
pictoMainGridView
.
startAnimation
(
this
.
showPictoMainViewAnimation
);
}
this
.
current
Category
=
null
;
this
.
current
Grid
=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
;
}
/**
...
...
@@ -424,11 +424,10 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
private
void
hidePictoMainGridView
()
{
this
.
pictoCategoryGridAdapter
.
clear
();
this
.
pictoCategoryGridAdapter
.
addAll
(
this
.
sort
(
this
.
vocabulary
.
next
(
this
.
getCurrentCategory
()
)));
this
.
pictoCategoryGridAdapter
.
addAll
(
this
.
sort
(
this
.
vocabulary
.
next
(
this
.
currentGrid
)));
this
.
pictoCategoryGridAdapter
.
notifyDataSetChanged
();
if
(
this
.
getCurrentCategory
().
get_color
()
!=
-
1
)
this
.
pictoCategoryGridView
.
setBackgroundColor
(
this
.
getCurrentCategory
().
get_color
());
Log
.
e
(
LOG_TAG
,
"Grid color:"
+
PCBcontext
.
getPcbdb
().
getGridColor
(
currentGrid
));
this
.
pictoCategoryGridView
.
setBackgroundColor
(
PCBcontext
.
getPcbdb
().
getGridColor
(
currentGrid
));
this
.
pictoMainGridView
.
setEnabled
(
false
);
this
.
pictoCategoryGridView
.
setEnabled
(
true
);
...
...
@@ -442,7 +441,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
* Returns pictoCategoryGridAdapter or pictoMainGridAdapter depending on the current View
*/
protected
PictoGridAdapter
getCurrentPictoGridAdapter
()
{
return
(
getCurrentCategory
()
==
null
)
?
this
.
pictoMainGridAdapter
:
this
.
pictoCategoryGridAdapter
;
return
(
this
.
currentGrid
==
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
)
?
this
.
pictoMainGridAdapter
:
this
.
pictoCategoryGridAdapter
;
}
/**
...
...
@@ -493,7 +492,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
getCurrentCategory
()
!=
null
)
{
if
(
VocabularyManager
.
this
.
currentGrid
!=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
)
{
hidePictoMainGridView
();
}
else
{
showPictoMainGridView
();
...
...
@@ -527,12 +526,6 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
}
}
/**
* @return
*/
public
Picto
getCurrentCategory
()
{
return
currentCategory
;
}
/* *********************************************************************************************
...
...
@@ -548,13 +541,11 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
if
(
inserting
)
return
;
Picto
p
=
getCurrentPictoGridAdapter
().
getItem
(
position
);
if
(
p
!=
null
&&
p
.
get_ImgId
()
!=
0
&&
!
p
.
is_invisible
()
&&
p
.
is_enabled
())
{
p
.
set_mirror
(
false
,
false
);
if
(
p
!=
null
&&
p
.
get_ImgId
()
!=
0
)
{
// If the has an associated grid
if
(
p
.
has_child_grid
())
{
currentCategory
=
vocabulary
.
get_stupicto
(
p
.
get_child_grid
());
currentGrid
=
p
.
get_child_grid
();
PCBcontext
.
getActionLog
().
log
(
new
TalkAction
(
TalkAction
.
SELECT
,
p
));
hidePictoMainGridView
();
}
...
...
@@ -614,8 +605,8 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
Log
.
e
(
LOG_TAG
,
"PREV:"
+
p
+(
p
!=
null
?
p
.
get_legend
()
:
"->nulo"
));
if
(
p
==
null
)
{
// No tengo pictograma. Abro una nueva ventana de selección desde el Carrete
int
cat
=
currentCategory
.
get_stupicto_id
();
new
PictoMenu
(
VocabularyManager
.
this
).
createMenuForNewPicto
(
position
%
maxColumns
,
(
int
)
(
position
/
maxColumns
),
c
at
);
new
PictoMenu
(
VocabularyManager
.
this
).
createMenuForNewPicto
(
position
%
maxColumns
,
(
int
)
(
position
/
maxColumns
),
c
urrentGrid
);
}
else
{
//Si es supervisor hacer aparecer el menú de opciones del picto
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoGridAdapter.java
View file @
dbbe1c3b
...
...
@@ -72,6 +72,7 @@ public class PictoGridAdapter extends ArrayAdapter {
public
void
pictoInGrid
(
Picto
p
)
{
p
.
set_visible
(
true
);
pictoLinkedList_inGrid
.
add
(
p
);
notifyDataSetChanged
();
}
...
...
@@ -82,9 +83,10 @@ public class PictoGridAdapter extends ArrayAdapter {
public
void
allPictosInGrid
()
{
for
(
Picto
picto:
pictoLinkedList_inTape
)
{
pictoLinkedList_inGrid
.
add
(
picto
);
}
for
(
Picto
picto:
pictoLinkedList_inTape
)
picto
.
set_visible
(
true
);
pictoLinkedList_inTape
.
clear
();
pictoLinkedList_inGrid
.
clear
();
notifyDataSetChanged
();
}
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/VOCA.java
View file @
dbbe1c3b
...
...
@@ -81,7 +81,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
// Tape view (list of pictos to send to the server)
GridView
tapeGridView
;
// Current picto category, if not null the corresponding category grid will be shown
private
Picto
currentCategory
;
private
int
currentGrid
;
// Object used for reading text
TTSHelper
tts
;
// Element used for loading new pictos (while changing categories)
...
...
@@ -129,7 +129,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
setContentView
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_picto_size_big
()
?
R
.
layout
.
voca_big
:
R
.
layout
.
voca
);
this
.
mainLayout
=
(
RelativeLayout
)
findViewById
(
R
.
id
.
pictogramLayout
);
this
.
current
Category
=
null
;
this
.
current
Grid
=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
;
this
.
count_deletelong
=
0
;
if
(!
PCBcontext
.
is_user_logged
())
{
Log
.
i
(
LOG_TAG
,
"No user logged. Restarting app"
);
...
...
@@ -289,7 +289,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
this
.
generateAnimations
();
if
(
this
.
getCurrentCategory
()
!=
null
)
{
if
(
this
.
currentGrid
!=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
)
{
this
.
hidePictoMainGridView
();
}
else
{
this
.
showPictoMainGridView
();
...
...
@@ -510,7 +510,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
this
.
pictoMainGridView
.
startAnimation
(
this
.
showPictoMainViewAnimation
);
}
this
.
current
Category
=
null
;
this
.
current
Grid
=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
;
}
/**
...
...
@@ -519,11 +519,9 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
private
void
hidePictoMainGridView
()
{
this
.
pictoCategoryGridAdapter
.
clear
();
this
.
pictoCategoryGridAdapter
.
addAll
(
this
.
sort
(
this
.
vocabulary
.
next
(
this
.
getCurrentCategory
()
)));
this
.
pictoCategoryGridAdapter
.
addAll
(
this
.
sort
(
this
.
vocabulary
.
next
(
currentGrid
)));
this
.
pictoCategoryGridAdapter
.
notifyDataSetChanged
();
if
(
this
.
getCurrentCategory
().
get_color
()
!=
-
1
)
this
.
pictoCategoryGridView
.
setBackgroundColor
(
this
.
getCurrentCategory
().
get_color
());
this
.
pictoCategoryGridView
.
setBackgroundColor
(
PCBcontext
.
getPcbdb
().
getGridColor
(
currentGrid
));
this
.
pictoMainGridView
.
setEnabled
(
false
);
this
.
pictoCategoryGridView
.
setEnabled
(
true
);
...
...
@@ -537,7 +535,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
* Returns pictoCategoryGridAdapter or pictoMainGridAdapter depending on the current View
*/
protected
PictoGridAdapter
getCurrentPictoGridAdapter
()
{
return
(
getCurrentCategory
()
==
null
)
?
this
.
pictoMainGridAdapter
:
this
.
pictoCategoryGridAdapter
;
return
(
currentGrid
==
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
)
?
this
.
pictoMainGridAdapter
:
this
.
pictoCategoryGridAdapter
;
}
/**
...
...
@@ -598,7 +596,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
getCurrentCategory
()
!=
null
)
{
if
(
currentGrid
!=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
()
)
{
hidePictoMainGridView
();
}
else
{
showPictoMainGridView
();
...
...
@@ -663,13 +661,6 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
}
}
/**
* @return
*/
public
Picto
getCurrentCategory
()
{
return
currentCategory
;
}
/* *********************************************************************************************
* Event listener classes
...
...
@@ -754,7 +745,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
// If the picto is a category
if
(
p
.
has_child_grid
())
{
current
Category
=
p
;
current
Grid
=
p
.
get_child_grid
()
;
PCBcontext
.
getActionLog
().
log
(
new
TalkAction
(
TalkAction
.
SELECT
,
p
));
hidePictoMainGridView
();
...
...
@@ -782,7 +773,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
private
void
addPictoWord
(
View
view
,
Picto
p
)
{
tapeAdapter
.
addItem
(
p
);
getCurrentPictoGridAdapter
().
pictoInTape
(
view
,
p
);
currentCategory
=
null
;
tapeAdapter
.
notifyDataSetChanged
();
showPictoMainGridView
();
PCBcontext
.
getActionLog
().
log
(
new
TalkAction
(
TalkAction
.
ADD
,
p
));
...
...
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