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
5764eef9
authored
Jun 22, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issues
#445
,
#435
,
#433
,
#427
,
#400
closed.
Issues
#448
,
#447
,
#446
in progress
parent
aad01231
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
26 deletions
android/Pictogram/app/build.gradle
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Device.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/ImgDownloader.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/NetService.java
android/Pictogram/app/src/main/res/values-en/strings.xml
android/Pictogram/app/src/main/res/values-es/strings.xml
android/Pictogram/app/build.gradle
View file @
5764eef9
...
...
@@ -14,29 +14,28 @@ android {
versionCode
1
versionName
"1.0"
signingConfig
signingConfigs
.
release_config
resValue
"string"
,
"db_name"
,
"PCB.db"
resValue
"string"
,
"core_vocabulary"
,
"core_vocabulary"
resValue
"integer"
,
"rows"
,
"5"
resValue
"integer"
,
"columns"
,
"10"
}
buildTypes
{
release
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
resValue
"string"
,
"server"
,
"https://pre.yottacode.com"
resValue
"string"
,
"db_name"
,
"PCB.db"
resValue
"bool"
,
"force_db_create"
,
"false"
resValue
"bool"
,
"ssl_connect"
,
"false"
resValue
"bool"
,
"force_img_download"
,
"false"
resValue
"integer"
,
"netservice_timing"
,
"20"
resValue
"integer"
,
"rows"
,
"5"
resValue
"integer"
,
"columns"
,
"10"
}
debug
{
resValue
"string"
,
"db_name"
,
"PCB.db"
resValue
"string"
,
"server"
,
"https://dev.yottacode.com"
resValue
"bool"
,
"force_db_create"
,
"false"
resValue
"bool"
,
"ssl_connect"
,
"false"
resValue
"bool"
,
"force_img_download"
,
"false"
resValue
"integer"
,
"netservice_timing"
,
"20"
resValue
"integer"
,
"rows"
,
"5"
resValue
"integer"
,
"columns"
,
"10"
}
}
productFlavors
{
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Device.java
View file @
5764eef9
...
...
@@ -21,6 +21,7 @@ import java.io.OutputStream;
import
java.util.Vector
;
import
com.yottacode.pictogram.R
;
import
com.yottacode.pictogram.gui.LoginActivity
;
import
com.yottacode.pictogram.tools.Img
;
import
com.yottacode.pictogram.net.ImgDownloader
;
...
...
@@ -411,8 +412,8 @@ public class Device extends SQLiteOpenHelper {
public
void
onCreate
(
SQLiteDatabase
db
)
throws
RuntimeException
{
try
{
executeSQLScript
(
db
,
DeviceHelper
.
getDBScriptStream
(
this
.
context
));
copyCoreVocabulary
();
Img
.
mkDirs
(
this
.
context
);
copyCoreVocabulary
();
}
catch
(
java
.
io
.
IOException
io
)
{
throw
new
RuntimeException
(
"Update database error"
,
io
);
}
...
...
@@ -421,8 +422,10 @@ public class Device extends SQLiteOpenHelper {
private
void
copyCoreVocabulary
()
{
AssetManager
assetManager
=
this
.
context
.
getAssets
();
String
[]
files
=
null
;
int
size
=
0
;
int
filesok
=
0
;
try
{
files
=
assetManager
.
list
(
"core_vocabulary"
);
files
=
assetManager
.
list
(
context
.
getResources
().
getString
(
R
.
string
.
core_vocabulary
)
);
}
catch
(
IOException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Failed to get asset file list."
,
e
);
}
...
...
@@ -430,39 +433,42 @@ public class Device extends SQLiteOpenHelper {
InputStream
in
=
null
;
OutputStream
out
=
null
;
try
{
in
=
assetManager
.
open
(
"core_vocabulary/"
+
"java"
+
"/"
+
filename
);
File
outFile
=
new
File
(
Img
.
path
(
this
.
context
,
Img
.
VOCABULARY
));
in
=
assetManager
.
open
(
context
.
getResources
().
getString
(
R
.
string
.
core_vocabulary
)+
File
.
separatorChar
+
filename
);
File
outFile
=
new
File
(
Img
.
path
(
this
.
context
,
Img
.
VOCABULARY
)
+
filename
);
out
=
new
FileOutputStream
(
outFile
);
copyFile
(
in
,
out
);
size
+=
copyFile
(
in
,
out
);
}
catch
(
IOException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Failed to copy asset
file: "
+
filename
,
e
);
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Failed to copy asset
image: "
+
context
.
getResources
().
getString
(
R
.
string
.
core_vocabulary
)+
File
.
separatorChar
+
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
fil
e: "
+
filename
,
e
);
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Failed to copy asset
imag
e: "
+
filename
,
e
);
}
}
if
(
out
!=
null
)
{
try
{
out
.
close
();
filesok
++;
}
catch
(
IOException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Failed to copy asset file: "
+
filename
,
e
);
}
}
}
}
Log
.
i
(
Device
.
class
.
getName
(),
"Core vocabulary Images installed ("
+
filesok
+
" pictos,"
+(
size
/
1024
)+
" KB)"
);
}
private
void
copyFile
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
private
int
copyFile
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
byte
[]
buffer
=
new
byte
[
8192
];
int
read
;
int
size
=
0
;
while
((
read
=
in
.
read
(
buffer
))
!=
-
1
){
out
.
write
(
buffer
,
0
,
read
);
size
+=
read
;
}
return
size
;
}
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/ImgDownloader.java
View file @
5764eef9
...
...
@@ -66,7 +66,6 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
try
{
for
(
Img
img:
imgs
)
{
if
(!
img
.
exists_bitmap
(
this
.
context
)
||
this
.
force_download
)
try
{
this
.
activityManager
.
getMemoryInfo
(
mi
);
if
(
this
.
source
==
source
.
remote
)
{
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/NetService.java
View file @
5764eef9
...
...
@@ -154,14 +154,20 @@ public class NetService implements Runnable {
PendingIntent
resultPendingIntent
=
stackBuilder
.
getPendingIntent
(
0
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
builder
.
setContentIntent
(
resultPendingIntent
);
String
user
=
""
;
if
(
PCBcontext
.
getPcbdb
()!=
null
)
{
user
=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_name_stu
();
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_supervisor
())
user
+=
" ("
+
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_name_sup
()
+
")"
;
}
if
(
updated
)
builder
.
setSmallIcon
(
R
.
drawable
.
application_online
)
.
setContentTitle
(
"Pictogram online"
)
.
setContentText
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
pictogram_online
)+
":"
+
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
server
)
);
.
setContentTitle
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
pictogram_online
)
)
.
setContentText
(
user
);
else
builder
.
setSmallIcon
(
R
.
drawable
.
application_offline
)
.
setContentTitle
(
"Pictogram offline"
)
.
setContentText
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
pictogram_offline
)
);
.
setContentTitle
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
pictogram_offline
)
)
.
setContentText
(
user
);
NotificationManager
mNotificationManager
=
(
NotificationManager
)
PCBcontext
.
getContext
().
getSystemService
(
PCBcontext
.
getContext
().
NOTIFICATION_SERVICE
);
...
...
android/Pictogram/app/src/main/res/values-en/strings.xml
View file @
5764eef9
...
...
@@ -54,6 +54,6 @@
<string
name=
"enterImgLabel"
>
Enter img label
</string>
<string
name=
"notNewCats"
>
Including new categories is not allowed
</string>
<!--online/offline status-->
<string
name=
"pictogram_offline"
>
Please check your internet connection.
</string>
<string
name=
"pictogram_online"
>
Server connection established.
</string>
<string
name=
"pictogram_offline"
>
Pictogram offline
</string>
<string
name=
"pictogram_online"
>
Pictogram online
</string>
</resources>
android/Pictogram/app/src/main/res/values-es/strings.xml
View file @
5764eef9
...
...
@@ -59,7 +59,7 @@
<string
name=
"enterImgLabel"
>
Introduzca etiqueta de la imagen
</string>
<string
name=
"notNewCats"
>
No puede añadir nuevas categorias
</string>
<!--online/offline status-->
<string
name=
"pictogram_offline"
>
Compruebe si tiene conexión a Internet.
</string>
<string
name=
"pictogram_online"
>
Conexón con el servidor establecida.
</string>
<string
name=
"pictogram_offline"
>
Pictogram offline
</string>
<string
name=
"pictogram_online"
>
Pictogram online
</string>
</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