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
aad01231
authored
Jun 21, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
working on PCB core vocabulary preloaded
parent
fb7fb727
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
95 additions
and
29 deletions
android/Pictogram/Pictogram.iml
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Device.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/PictoGridAdapter.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/PictoItemViewGenerator.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/PictogramActivity.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/StudentFragmentGrid.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/NetService.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/tools/Img.java
android/Pictogram/app/src/main/res/values-en/strings.xml
android/Pictogram/app/src/main/res/values-es/strings.xml
android/Pictogram/app/src/main/res/values/dimens.xml
android/Pictogram/app/src/main/res/values/strings.xml
android/Pictogram/Pictogram.iml
View file @
aad01231
...
...
@@ -13,7 +13,7 @@
<content
url=
"file://$MODULE_DIR$"
>
<excludeFolder
url=
"file://$MODULE_DIR$/.gradle"
/>
</content>
<orderEntry
type=
"
inheritedJdk
"
/>
<orderEntry
type=
"
jdk"
jdkName=
"1.8"
jdkType=
"JavaSDK
"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
\ No newline at end of file
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Device.java
View file @
aad01231
...
...
@@ -3,6 +3,7 @@ package com.yottacode.pictogram.dao;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.content.res.AssetManager
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteDatabase.CursorFactory
;
...
...
@@ -11,9 +12,12 @@ import android.os.AsyncTask;
import
android.util.Log
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.InputStreamReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.Vector
;
...
...
@@ -21,6 +25,7 @@ import com.yottacode.pictogram.gui.LoginActivity;
import
com.yottacode.pictogram.tools.Img
;
import
com.yottacode.pictogram.net.ImgDownloader
;
import
com.yottacode.pictogram.net.iImgDownloaderListener
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
org.json.JSONException
;
...
...
@@ -406,14 +411,63 @@ public class Device extends SQLiteOpenHelper {
public
void
onCreate
(
SQLiteDatabase
db
)
throws
RuntimeException
{
try
{
executeSQLScript
(
db
,
DeviceHelper
.
getDBScriptStream
(
this
.
context
));
copyCoreVocabulary
();
Img
.
mkDirs
(
this
.
context
);
}
catch
(
java
.
io
.
IOException
io
)
{
throw
new
RuntimeException
(
"Update database error"
,
io
);
}
}
@Override
private
void
copyCoreVocabulary
()
{
AssetManager
assetManager
=
this
.
context
.
getAssets
();
String
[]
files
=
null
;
try
{
files
=
assetManager
.
list
(
"core_vocabulary"
);
}
catch
(
IOException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Failed to get asset file list."
,
e
);
}
if
(
files
!=
null
)
for
(
String
filename
:
files
)
{
InputStream
in
=
null
;
OutputStream
out
=
null
;
try
{
in
=
assetManager
.
open
(
"core_vocabulary/"
+
"java"
+
"/"
+
filename
);
File
outFile
=
new
File
(
Img
.
path
(
this
.
context
,
Img
.
VOCABULARY
));
out
=
new
FileOutputStream
(
outFile
);
copyFile
(
in
,
out
);
}
catch
(
IOException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Failed to copy asset file: "
+
filename
,
e
);
}
finally
{
if
(
in
!=
null
)
{
try
{
in
.
close
();
Log
.
i
(
Device
.
class
.
getName
(),
"Core vocabulary copied ("
+
files
.
length
+
" pictos)"
);
}
catch
(
IOException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Failed to copy asset file: "
+
filename
,
e
);
}
}
if
(
out
!=
null
)
{
try
{
out
.
close
();
}
catch
(
IOException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Failed to copy asset file: "
+
filename
,
e
);
}
}
}
}
}
private
void
copyFile
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
byte
[]
buffer
=
new
byte
[
8192
];
int
read
;
while
((
read
=
in
.
read
(
buffer
))
!=
-
1
){
out
.
write
(
buffer
,
0
,
read
);
}
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
}
}
\ No newline at end of file
}
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/PictoGridAdapter.java
View file @
aad01231
...
...
@@ -69,4 +69,4 @@ public class PictoGridAdapter extends ArrayAdapter {
tts
.
speak
(
input
,
TextToSpeech
.
QUEUE_FLUSH
,
params
,
null
);
}
}
}
\ No newline at end of file
}
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/PictoItemViewGenerator.java
View file @
aad01231
package
com
.
yottacode
.
pictogram
.
gui
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -40,7 +41,11 @@ public class PictoItemViewGenerator {
pictoImage
.
setScaleY
(
1.0f
);
pictoImage
.
setVisibility
(
View
.
GONE
);
if
(
picto
!=
null
)
{
if
(
picto
==
null
)
{
layoutWrapper
.
setVisibility
(
View
.
VISIBLE
);
layoutWrapper
.
setBackground
(
convertView
.
getResources
()
.
getDrawable
(
R
.
drawable
.
picto_grid_item_border
));
}
else
{
if
(!
picto
.
is_invisible
()
&&
!
picto
.
is_disabled
())
{
layoutWrapper
.
setAlpha
(
1.00f
);
}
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/PictogramActivity.java
View file @
aad01231
...
...
@@ -594,10 +594,13 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
*/
private
class
OnPictoLongClickListener
implements
AdapterView
.
OnItemLongClickListener
{
public
boolean
onItemLongClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
Log
.
d
(
LOG_TAG
,
"long click 1"
);
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_supervisor
())
{
Log
.
d
(
LOG_TAG
,
"long click 2"
);
// Si es supervisor al hacer longClick deshabilito ese pictograma o lo habilito
Picto
p
=
getCurrentPictoGridAdapter
().
getItem
(
position
);
if
(
p
==
null
)
{
Log
.
d
(
LOG_TAG
,
"long click 3"
);
// No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device si no es categoria
if
(
currentCategory
!=
null
)
{
Log
.
d
(
LOG_TAG
,
"No tengo pictograma. Abro carrete..."
);
...
...
@@ -608,7 +611,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
}
else
{
p
.
alter_status
();
showPictoMainGridView
();
pictoCategoryGridAdapter
.
notifyDataSetChanged
();
}
}
else
{
ClipData
.
Item
item
=
new
ClipData
.
Item
(
""
+
position
);
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/StudentFragmentGrid.java
View file @
aad01231
...
...
@@ -131,6 +131,7 @@ public class StudentFragmentGrid extends Fragment{
}
});
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
Log
.
e
(
StudentFragmentGrid
.
this
.
getClass
().
getCanonicalName
(),
e
.
getMessage
());
...
...
@@ -290,4 +291,4 @@ public class StudentFragmentGrid extends Fragment{
if
(
offline
||
onlineStudentsOK
)
showStudentsGrid
();
return
view
;
}
}
\ No newline at end of file
}
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/NetService.java
View file @
aad01231
...
...
@@ -157,7 +157,7 @@ public class NetService implements Runnable {
if
(
updated
)
builder
.
setSmallIcon
(
R
.
drawable
.
application_online
)
.
setContentTitle
(
"Pictogram online"
)
.
setContentText
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
pictogram_online
));
.
setContentText
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
pictogram_online
)
+
":"
+
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
server
)
);
else
builder
.
setSmallIcon
(
R
.
drawable
.
application_offline
)
.
setContentTitle
(
"Pictogram offline"
)
...
...
@@ -168,4 +168,4 @@ public class NetService implements Runnable {
// mId allows you to update the notification later on.
mNotificationManager
.
notify
(
notifyID
,
builder
.
build
());
}
}
\ No newline at end of file
}
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
View file @
aad01231
package
com
.
yottacode
.
pictogram
.
net
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.util.Log
;
import
com.google.gson.JsonObject
;
...
...
@@ -11,6 +13,7 @@ import com.yottacode.pictogram.action.VocabularyAction;
import
com.yottacode.pictogram.dao.Picto
;
import
com.yottacode.pictogram.tools.Img
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.tools.BitmapTools
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
...
...
@@ -33,15 +36,21 @@ public class PictoUploader {
private
int
uploadImg
(
Img
img
)
throws
UnsupportedEncodingException
{
int
img_id
;
Bitmap
bmp
=
null
;
if
(!
img
.
get_filetype
().
equalsIgnoreCase
(
"png"
))
throw
new
UnsupportedEncodingException
(
"Extension "
+
img
.
get_filetype
()+
" is not supported. Only png files"
);
Ion
ion
=
Ion
.
getDefault
(
PCBcontext
.
getContext
());
try
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Uploading Picto img"
+
img
.
file_name
()
+
" from "
+
img
.
get_type
()
+
"size:"
+
img
.
get_bitmap
(
PCBcontext
.
getContext
()).
getWidth
()
+
" "
+
img
.
get_bitmap
(
PCBcontext
.
getContext
()).
getHeight
());
}
catch
(
IOException
e
)
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Uploading Picto img"
+
img
.
file_name
()
+
" from "
+
img
.
get_type
());
}
try
{
bmp
=
img
.
get_bitmap
(
PCBcontext
.
getContext
());
}
catch
(
IOException
e
)
{
Log
.
e
(
Img
.
class
.
getCanonicalName
(),
"Error when decoding "
+
img
.
file_name
());
}
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Uploading Picto img"
+
img
.
file_name
()
+
" from "
+
img
.
get_type
()
+
"size:"
+
bmp
.
getWidth
()
+
" "
+
bmp
.
getHeight
());
File
file
=
img
.
file
(
PCBcontext
.
getContext
());
Response
<
JsonObject
>
response
=
null
;
...
...
@@ -160,7 +169,6 @@ public class PictoUploader {
*
**/
public
void
upload
()
throws
IOException
{
int
old_picto
=
this
.
picto
.
get_id
();
int
img_id
=
uploadImg
(
this
.
picto
);
if
(
img_id
>
0
)
{
uploadAttributes
(
img_id
);
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/tools/Img.java
View file @
aad01231
...
...
@@ -27,7 +27,7 @@ public class Img {
static
public
String
VOCABULARY
=
"vocabulary"
;
static
public
String
STUDENT
=
"student"
;
static
public
String
SUPERVISOR
=
"supervisor"
;
static
public
float
MAX_WIDTH
=
100
;
public
static
final
void
mkDirs
(
Context
context
)
{
File
file
;
file
=
new
File
(
path
(
context
,
Img
.
VOCABULARY
));
...
...
@@ -126,7 +126,6 @@ public class Img {
* @throws IOException
*/
public
int
save_bitmap
(
Context
context
,
InputStream
is
)
throws
IOException
{
final
float
MAX_WIDTH
=
100
;
File
file
=
file
(
context
);
FileOutputStream
os
=
new
FileOutputStream
(
file
);
try
{
...
...
android/Pictogram/app/src/main/res/values-en/strings.xml
View file @
aad01231
...
...
@@ -45,7 +45,7 @@
<string
name=
"serverError"
>
There is a server error. Try again later
</string>
<!--Semantic grammar -->
<string
name=
"loadingGrammar"
>
Please wait, loading
semmantic grammar
</string>
<string
name=
"loadingGrammar"
>
Please wait, loading
vocabulary
</string>
<string
name=
"naturalgrammar"
>
SUpO_EN
</string>
<string
name=
"pictogrammar"
>
SUpO_PICTOEN
</string>
<string
name=
"nogrammar"
>
Warning: unknown language
</string>
...
...
android/Pictogram/app/src/main/res/values-es/strings.xml
View file @
aad01231
...
...
@@ -47,7 +47,7 @@
<string
name=
"serverError"
>
Error en el servidor de datos. Inténtelo más tarde
</string>
<!--Semantic grammar -->
<string
name=
"loadingGrammar"
>
Por favor espere, cargando
gramática semántica
</string>
<string
name=
"loadingGrammar"
>
Por favor espere, cargando
vocabulario
</string>
<string
name=
"naturalgrammar"
>
SUpO_ES
</string>
<string
name=
"grammar"
>
SUpO_ES
</string>
<string
name=
"nogrammar"
>
Advertencia: Lenguaje no soportado
</string>
...
...
android/Pictogram/app/src/main/res/values/dimens.xml
View file @
aad01231
...
...
@@ -7,7 +7,7 @@
<dimen
name=
"picto_grid_spacing"
>
4dp
</dimen>
<dimen
name=
"picto_border_width"
>
1dp
</dimen>
<dimen
name=
"picto_padding"
>
4dp
</dimen>
<dimen
name=
"picto_normal_height"
>
80
dp
</dimen>
<dimen
name=
"picto_normal_width"
>
80
dp
</dimen>
<dimen
name=
"tape_normal_height"
>
10
0dp
</dimen>
<dimen
name=
"picto_normal_height"
>
75
dp
</dimen>
<dimen
name=
"picto_normal_width"
>
75
dp
</dimen>
<dimen
name=
"tape_normal_height"
>
9
0dp
</dimen>
</resources>
android/Pictogram/app/src/main/res/values/strings.xml
View file @
aad01231
...
...
@@ -47,7 +47,7 @@
<string
name=
"serverError"
>
Error en el servidor de datos. Inténtelo más tarde
</string>
<!--Semantic grammar -->
<string
name=
"loadingGrammar"
>
Please wait, loading
semmantic grammar
</string>
<string
name=
"loadingGrammar"
>
Please wait, loading
vocabulary
</string>
<string
name=
"naturalgrammar"
>
SUpO_EN
</string>
<string
name=
"grammar"
>
SUpO_EN
</string>
<string
name=
"nogrammar"
>
Warning: unknown language
</string>
...
...
@@ -75,4 +75,4 @@
<string
name=
"pictogram_offline"
>
Compruebe si tiene conexión a Internet.
</string>
<string
name=
"pictogram_online"
>
Conexón con el servidor establecida.
</string>
</string>
</resources>
\ No newline at end of file
</resources>
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