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
b80d53d5
authored
Mar 16, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
wirking on notification online/offline tray
parent
e96e2819
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
4 deletions
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Device.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/src/main/res/values/strings.xml
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Device.java
View file @
b80d53d5
...
@@ -235,7 +235,7 @@ public class Device extends SQLiteOpenHelper {
...
@@ -235,7 +235,7 @@ public class Device extends SQLiteOpenHelper {
Vector
<
User
>
users
=
null
;
Vector
<
User
>
users
=
null
;
Cursor
cursor
=
db
.
query
(
"supervisor"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
Cursor
cursor
=
db
.
query
(
"supervisor"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
while
(
cursor
.
moveToNext
()
&&
users
==
null
&&
!
user_found
)
{
while
(
cursor
.
moveToNext
()
&&
users
==
null
&&
!
user_found
)
{
user_found
=
cursor
.
getString
(
1
0
).
equalsIgnoreCase
(
auser
);
user_found
=
cursor
.
getString
(
1
).
equalsIgnoreCase
(
auser
);
if
(
user_found
)
if
(
user_found
)
if
(
cursor
.
getString
(
2
).
equals
(
apwd
))
{
if
(
cursor
.
getString
(
2
).
equals
(
apwd
))
{
users
=
recoverStudents
(
cursor
.
getInt
(
0
));
users
=
recoverStudents
(
cursor
.
getInt
(
0
));
...
@@ -301,7 +301,7 @@ public class Device extends SQLiteOpenHelper {
...
@@ -301,7 +301,7 @@ public class Device extends SQLiteOpenHelper {
"lang_stu='"
+
user
.
get_lang_stu
()
+
"', "
+
"lang_stu='"
+
user
.
get_lang_stu
()
+
"', "
+
"attributes_stu='"
+
user
.
get_json_attrs
()
+
"', "
+
"attributes_stu='"
+
user
.
get_json_attrs
()
+
"', "
+
"name_sup='"
+
user
.
get_name_sup
()
+
"', "
+
"name_sup='"
+
user
.
get_name_sup
()
+
"', "
+
"
nickname
_sup='"
+
user
.
get_email_sup
()
+
"', "
+
"
email
_sup='"
+
user
.
get_email_sup
()
+
"', "
+
"pwd_sup='"
+
user
.
get_pwd_sup
()
+
"', "
+
"pwd_sup='"
+
user
.
get_pwd_sup
()
+
"', "
+
"surname_sup='"
+
user
.
get_surname_sup
()
+
"', "
+
"surname_sup='"
+
user
.
get_surname_sup
()
+
"', "
+
"url_img_sup='"
+
user
.
get_url_img_sup
()
+
"', "
+
"url_img_sup='"
+
user
.
get_url_img_sup
()
+
"', "
+
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/NetService.java
View file @
b80d53d5
package
com
.
yottacode
.
pictogram
.
net
;
package
com
.
yottacode
.
pictogram
.
net
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.app.TaskStackBuilder
;
import
android.content.Intent
;
import
android.support.v4.app.NotificationCompat
;
import
android.util.Log
;
import
android.util.Log
;
import
com.yottacode.net.RestapiWrapper
;
import
com.yottacode.net.RestapiWrapper
;
import
com.yottacode.net.iRestapiListener
;
import
com.yottacode.net.iRestapiListener
;
import
com.yottacode.pictogram.R
;
import
com.yottacode.pictogram.R
;
import
com.yottacode.pictogram.gui.PictogramActivity
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
...
@@ -32,8 +38,20 @@ public class NetService implements Runnable {
...
@@ -32,8 +38,20 @@ public class NetService implements Runnable {
static
final
String
ping_session
=
"server/ping"
;
static
final
String
ping_session
=
"server/ping"
;
private
boolean
updated
;
private
boolean
updated
;
private
NotificationCompat
.
Builder
builder
;
public
NetService
(
int
delay
)
{
public
NetService
(
int
delay
)
{
this
.
builder
=
new
NotificationCompat
.
Builder
(
PCBcontext
.
getContext
());
Intent
resultIntent
=
new
Intent
(
PCBcontext
.
getContext
(),
PictogramActivity
.
class
);
TaskStackBuilder
stackBuilder
=
TaskStackBuilder
.
create
(
PCBcontext
.
getContext
());
stackBuilder
.
addParentStack
(
PictogramActivity
.
class
);
stackBuilder
.
addNextIntent
(
resultIntent
);
PendingIntent
resultPendingIntent
=
stackBuilder
.
getPendingIntent
(
0
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
this
.
builder
.
setContentIntent
(
resultPendingIntent
);
this
.
updated
=
RestapiWrapper
.
ping
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
server
),
ping_session
,
new
iRestapiListener
()
{
this
.
updated
=
RestapiWrapper
.
ping
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
server
),
ping_session
,
new
iRestapiListener
()
{
@Override
@Override
public
void
preExecute
()
{
public
void
preExecute
()
{
...
@@ -47,11 +65,13 @@ public class NetService implements Runnable {
...
@@ -47,11 +65,13 @@ public class NetService implements Runnable {
@Override
@Override
public
void
result
(
JSONObject
result
)
{
public
void
result
(
JSONObject
result
)
{
updated
=
true
;
updated
=
true
;
notifyStatus
();
}
}
@Override
@Override
public
void
error
(
Exception
e
)
{
public
void
error
(
Exception
e
)
{
updated
=
false
;
updated
=
false
;
notifyStatus
();
}
}
});
});
Log
.
i
(
this
.
getClass
().
getName
(),
"Checking Pictogram server access..."
);
Log
.
i
(
this
.
getClass
().
getName
(),
"Checking Pictogram server access..."
);
...
@@ -91,6 +111,7 @@ public class NetService implements Runnable {
...
@@ -91,6 +111,7 @@ public class NetService implements Runnable {
updated
=
true
;
updated
=
true
;
}
}
Log
.
i
(
this
.
getClass
().
getName
(),
"PCB status checked. Updated? "
+
updated
);
Log
.
i
(
this
.
getClass
().
getName
(),
"PCB status checked. Updated? "
+
updated
);
notifyStatus
();
}
}
@Override
@Override
...
@@ -101,4 +122,20 @@ public class NetService implements Runnable {
...
@@ -101,4 +122,20 @@ public class NetService implements Runnable {
});
});
}
}
private
void
notifyStatus
()
{
int
notifyID
=
1
;
this
.
builder
.
setSmallIcon
(
R
.
drawable
.
logo_pictogram
)
.
setContentTitle
(
"Pictogram "
+
(
updated
?
"online"
:
"offline"
))
.
setContentText
(
updated
?
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
pictogram_online
)
:
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
pictogram_offline
));
NotificationManager
mNotificationManager
=
(
NotificationManager
)
PCBcontext
.
getContext
().
getSystemService
(
PCBcontext
.
getContext
().
NOTIFICATION_SERVICE
);
// mId allows you to update the notification later on.
mNotificationManager
.
notify
(
notifyID
,
this
.
builder
.
build
());
}
}
}
\ No newline at end of file
android/Pictogram/app/src/main/res/values-en/strings.xml
View file @
b80d53d5
...
@@ -51,5 +51,7 @@
...
@@ -51,5 +51,7 @@
<!--Upload local img -->
<!--Upload local img -->
<string
name=
"enterImgLabel"
>
Enter img label
</string>
<string
name=
"enterImgLabel"
>
Enter img label
</string>
<string
name=
"notNewCats"
>
Including new categories is not allowed
</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"
>
Pictogram server connection established.
</string>
</resources>
</resources>
android/Pictogram/app/src/main/res/values-es/strings.xml
View file @
b80d53d5
...
@@ -55,5 +55,7 @@
...
@@ -55,5 +55,7 @@
<!--Upload local img -->
<!--Upload local img -->
<string
name=
"enterImgLabel"
>
Introduzca etiqueta de la imagen
</string>
<string
name=
"enterImgLabel"
>
Introduzca etiqueta de la imagen
</string>
<string
name=
"notNewCats"
>
No puede añadir nuevas categorias
</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 Pictogram establecida.
</string>
</resources>
</resources>
android/Pictogram/app/src/main/res/values/strings.xml
View file @
b80d53d5
...
@@ -68,5 +68,8 @@
...
@@ -68,5 +68,8 @@
<string
name=
"error_field_required"
>
This field is required
</string>
<string
name=
"error_field_required"
>
This field is required
</string>
<string
name=
"permission_rationale"
>
"Contacts permissions are needed for providing email
<string
name=
"permission_rationale"
>
"Contacts permissions are needed for providing email
completions."
completions."
<!--online/offline status-->
<string
name=
"pictogram_offline"
>
Compruebe si tiene conexión a Internet.
</string>
<string
name=
"pictogram_online"
>
Conexón con el servidor Pictogram establecida.
</string>
</string>
</string>
</resources>
</resources>
\ No newline at end of file
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