Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
android-client
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
icarus
android-client
Commits
f412b4ed
You need to sign in or sign up before continuing.
Commit
f412b4ed
authored
May 03, 2018
by
Mattia Ducci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor fixes e refactoring
parent
83f59424
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
158 additions
and
101 deletions
+158
-101
MainActivity.java
.../everywaretechnologies/it/icarusandroid/MainActivity.java
+11
-9
activity_main.xml
IcarusAndroid/app/src/main/res/layout/activity_main.xml
+26
-11
EventTrackResource.java
...k/everywaretechnologies/it/icarus/EventTrackResource.java
+31
-16
Icarus.java
...ava/framework/everywaretechnologies/it/icarus/Icarus.java
+34
-15
UserSettingsResource.java
...everywaretechnologies/it/icarus/UserSettingsResource.java
+56
-50
No files found.
IcarusAndroid/app/src/main/java/framework/everywaretechnologies/it/icarusandroid/MainActivity.java
View file @
f412b4ed
...
@@ -29,8 +29,8 @@ public class MainActivity extends AppCompatActivity {
...
@@ -29,8 +29,8 @@ public class MainActivity extends AppCompatActivity {
private
Icarus
instance
;
private
Icarus
instance
;
private
EditText
eventNameEditText
;
private
EditText
eventNameEditText
;
private
EditText
eventCategoryEditText
;
Switch
eventCategorySwitch
;
private
EditText
eventLabelEditText
;
Switch
eventLabelSwitch
;
private
EditText
mostProbableActivityEditText
;
private
EditText
mostProbableActivityEditText
;
@Override
@Override
...
@@ -61,8 +61,8 @@ public class MainActivity extends AppCompatActivity {
...
@@ -61,8 +61,8 @@ public class MainActivity extends AppCompatActivity {
else
intPrefSwitch
.
setChecked
(
true
);
else
intPrefSwitch
.
setChecked
(
true
);
eventNameEditText
=
findViewById
(
R
.
id
.
editText_eventName
);
eventNameEditText
=
findViewById
(
R
.
id
.
editText_eventName
);
eventCategory
EditText
=
findViewById
(
R
.
id
.
editText_eventCategory
);
eventCategory
Switch
=
findViewById
(
R
.
id
.
event_category_switch
);
eventLabel
EditText
=
findViewById
(
R
.
id
.
editText_eventLabel
);
eventLabel
Switch
=
findViewById
(
R
.
id
.
event_label_switch
);
mostProbableActivityEditText
=
findViewById
(
R
.
id
.
editText_mostProbableActivity
);
mostProbableActivityEditText
=
findViewById
(
R
.
id
.
editText_mostProbableActivity
);
}
}
...
@@ -106,16 +106,18 @@ public class MainActivity extends AppCompatActivity {
...
@@ -106,16 +106,18 @@ public class MainActivity extends AppCompatActivity {
Log
.
d
(
CLASS_NAME
,
"on btn track event"
);
Log
.
d
(
CLASS_NAME
,
"on btn track event"
);
String
eventName
,
eventCategory
,
eventLabel
,
mostProbableActivity
;
String
eventName
,
mostProbableActivity
;
EventTrackResource
.
EventCategory
eventCategory
;
EventTrackResource
.
EventLabel
eventLabel
;
if
(
eventNameEditText
.
getText
().
length
()
==
0
)
eventName
=
"eventoProva"
;
if
(
eventNameEditText
.
getText
().
length
()
==
0
)
eventName
=
"eventoProva"
;
else
eventName
=
eventNameEditText
.
getText
().
toString
();
else
eventName
=
eventNameEditText
.
getText
().
toString
();
if
(
eventCategoryEditText
.
getText
().
length
()==
0
)
eventCategory
=
EventTrackResource
.
EventCategories
.
APPLICATION
.
name
().
toLowerCase
()
;
if
(
!
eventCategorySwitch
.
isChecked
())
eventCategory
=
EventTrackResource
.
EventCategory
.
APPLICATION
;
else
eventCategory
=
eventCategoryEditText
.
getText
().
toString
()
;
else
eventCategory
=
EventTrackResource
.
EventCategory
.
ACTION
;
if
(
eventLabelEditText
.
getText
().
length
()==
0
)
eventLabel
=
EventTrackResource
.
EventLabel
.
FOREGROUND
.
name
().
toLowerCase
()
;
if
(
!
eventLabelSwitch
.
isChecked
())
eventLabel
=
EventTrackResource
.
EventLabel
.
FOREGROUND
;
else
eventLabel
=
eventLabelEditText
.
getText
().
toString
()
;
else
eventLabel
=
EventTrackResource
.
EventLabel
.
BACKGROUND
;
if
(
mostProbableActivityEditText
.
getText
().
length
()==
0
)
mostProbableActivity
=
"running"
;
if
(
mostProbableActivityEditText
.
getText
().
length
()==
0
)
mostProbableActivity
=
"running"
;
else
mostProbableActivity
=
mostProbableActivityEditText
.
getText
().
toString
();
else
mostProbableActivity
=
mostProbableActivityEditText
.
getText
().
toString
();
...
...
IcarusAndroid/app/src/main/res/layout/activity_main.xml
View file @
f412b4ed
...
@@ -75,6 +75,14 @@
...
@@ -75,6 +75,14 @@
android:text=
"Invia pref changes"
/>
android:text=
"Invia pref changes"
/>
<TextView
android:id=
"@+id/textView"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Track event"
android:textColor=
"@android:color/holo_red_light"
android:textSize=
"24sp"
/>
<EditText
<EditText
android:id=
"@+id/editText_eventName"
android:id=
"@+id/editText_eventName"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -83,28 +91,35 @@
...
@@ -83,28 +91,35 @@
android:hint=
"event name"
android:hint=
"event name"
android:inputType=
"textPersonName"
/>
android:inputType=
"textPersonName"
/>
<
EditText
<
Switch
android:id=
"@+id/e
ditText_eventCategory
"
android:id=
"@+id/e
vent_category_switch
"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:ems=
"18"
android:showText=
"true"
android:hint=
"event category"
android:splitTrack=
"false"
android:inputType=
"textPersonName"
/>
android:text=
"Event category"
android:textOff=
"application"
android:textOn=
"action"
android:textSize=
"18sp"
/>
<
EditText
<
Switch
android:id=
"@+id/e
ditText_eventLabel
"
android:id=
"@+id/e
vent_label_switch
"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:ems=
"18"
android:showText=
"true"
android:hint=
"event label"
android:splitTrack=
"false"
android:inputType=
"textPersonName"
/>
android:text=
"Event label"
android:textOff=
"foreground"
android:textOn=
"background"
android:textSize=
"18sp"
/>
<EditText
<EditText
android:id=
"@+id/editText_mostProbableActivity"
android:id=
"@+id/editText_mostProbableActivity"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:ems=
"18"
android:ems=
"18"
android:hint=
"
most probable activity
"
android:hint=
"
activity: walking or cycling. empty for running
"
android:inputType=
"textPersonName"
/>
android:inputType=
"textPersonName"
/>
<Button
<Button
...
...
IcarusAndroid/icarus/src/main/java/framework/everywaretechnologies/it/icarus/EventTrackResource.java
View file @
f412b4ed
...
@@ -5,7 +5,22 @@ import org.json.JSONObject;
...
@@ -5,7 +5,22 @@ import org.json.JSONObject;
public
class
EventTrackResource
extends
IcarusResource
{
public
class
EventTrackResource
extends
IcarusResource
{
public
enum
EventCategories
{
//categorie di evento
//------------ JSON KEYS --------------------
private
final
static
String
CONFIDENCE_KEY
=
"confidence"
;
private
final
static
String
START_TIMESTAMP_KEY
=
"startTimestamp"
;
private
final
static
String
HEADING_KEY
=
"heading"
;
private
final
static
String
COURSE_KEY
=
"course"
;
private
final
static
String
SPEED_KEY
=
"speed"
;
private
final
static
String
ACTIVITY_KEY
=
"activity"
;
private
final
static
String
DIRECTION_KEY
=
"direction"
;
private
final
static
String
EVENT_NAME_KEY
=
"EventName"
;
private
final
static
String
EVENT_CATEGORY_KEY
=
"EventCategory"
;
private
final
static
String
EVENT_LABEL_KEY
=
"EventLabel"
;
private
final
static
String
EVENT_CONTEXT_KEY
=
"EventContext"
;
//-----------------------------------------------------
public
enum
EventCategory
{
//categorie di evento
APPLICATION
,
ACTION
,
NOTIFICATION
;
APPLICATION
,
ACTION
,
NOTIFICATION
;
}
}
...
@@ -16,8 +31,8 @@ public class EventTrackResource extends IcarusResource {
...
@@ -16,8 +31,8 @@ public class EventTrackResource extends IcarusResource {
}
}
private
String
eventName
;
private
String
eventName
;
private
String
eventCategory
;
private
EventCategory
eventCategory
;
private
String
eventLabel
;
private
EventLabel
eventLabel
;
private
int
heading
;
private
int
heading
;
private
int
course
;
private
int
course
;
...
@@ -25,7 +40,7 @@ public class EventTrackResource extends IcarusResource {
...
@@ -25,7 +40,7 @@ public class EventTrackResource extends IcarusResource {
//i due successivi attributi sono quelli ritornati dall'ActivityRecognition di Google che dev'essere implementata nell'app chiamante
//i due successivi attributi sono quelli ritornati dall'ActivityRecognition di Google che dev'essere implementata nell'app chiamante
//convertiti da quelli di Google a quelli del server.. vedi iMoveAndroid per il metodo di mapping tra i valori ritornati da Google e quelli
//convertiti da quelli di Google a quelli del server.. vedi iMoveAndroid per il metodo di mapping tra i valori ritornati da Google e quelli
//per il server di ewtech. Fare copia incolla del metodo in progetti futuri. Non lo metto qua perchè non ho accesso ai codici delle attività
//per il server di ewtech. Fare copia incolla del metodo in progetti futuri. Non lo metto qua perchè
da qua
non ho accesso ai codici delle attività
//non avendo la dipendenza all'ActivityRecognition all'interno di questa libreria
//non avendo la dipendenza all'ActivityRecognition all'interno di questa libreria
private
String
mostProbableUserActivityName
;
private
String
mostProbableUserActivityName
;
private
int
confidence
;
private
int
confidence
;
...
@@ -34,7 +49,7 @@ public class EventTrackResource extends IcarusResource {
...
@@ -34,7 +49,7 @@ public class EventTrackResource extends IcarusResource {
private
String
[]
userActivityToTrack
;
private
String
[]
userActivityToTrack
;
public
EventTrackResource
(
String
_eventName
,
String
_eventCategory
,
String
_eventLabel
,
int
_heading
,
int
_course
,
int
_speed
,
public
EventTrackResource
(
String
_eventName
,
EventCategory
_eventCategory
,
EventLabel
_eventLabel
,
int
_heading
,
int
_course
,
int
_speed
,
String
_mostProbableUserActivityName
,
int
_confidence
,
boolean
_accessibilityEnabled
){
String
_mostProbableUserActivityName
,
int
_confidence
,
boolean
_accessibilityEnabled
){
super
();
super
();
...
@@ -66,8 +81,8 @@ public class EventTrackResource extends IcarusResource {
...
@@ -66,8 +81,8 @@ public class EventTrackResource extends IcarusResource {
userActivityJSONObject
.
put
(
activityType
,
false
);
userActivityJSONObject
.
put
(
activityType
,
false
);
}
}
userActivityJSONObject
.
put
(
"confidence"
,
confidence
);
userActivityJSONObject
.
put
(
CONFIDENCE_KEY
,
confidence
);
userActivityJSONObject
.
put
(
"startTimestamp"
,
System
.
currentTimeMillis
());
userActivityJSONObject
.
put
(
START_TIMESTAMP_KEY
,
System
.
currentTimeMillis
());
}
catch
(
JSONException
jsonException
){
}
catch
(
JSONException
jsonException
){
...
@@ -78,8 +93,8 @@ public class EventTrackResource extends IcarusResource {
...
@@ -78,8 +93,8 @@ public class EventTrackResource extends IcarusResource {
try
{
try
{
directionJSONObject
.
put
(
"heading"
,
heading
);
//0..360
directionJSONObject
.
put
(
HEADING_KEY
,
heading
);
//0..360
directionJSONObject
.
put
(
"course"
,
course
);
//0..360
directionJSONObject
.
put
(
COURSE_KEY
,
course
);
//0..360
}
catch
(
JSONException
jsonException
){
}
catch
(
JSONException
jsonException
){
...
@@ -90,9 +105,9 @@ public class EventTrackResource extends IcarusResource {
...
@@ -90,9 +105,9 @@ public class EventTrackResource extends IcarusResource {
try
{
try
{
eventContextJSONObject
.
put
(
"speed"
,
speed
);
eventContextJSONObject
.
put
(
SPEED_KEY
,
speed
);
eventContextJSONObject
.
put
(
"activity"
,
userActivityJSONObject
);
eventContextJSONObject
.
put
(
ACTIVITY_KEY
,
userActivityJSONObject
);
eventContextJSONObject
.
put
(
"direction"
,
directionJSONObject
);
eventContextJSONObject
.
put
(
DIRECTION_KEY
,
directionJSONObject
);
}
catch
(
JSONException
jsonException
){
}
catch
(
JSONException
jsonException
){
...
@@ -103,10 +118,10 @@ public class EventTrackResource extends IcarusResource {
...
@@ -103,10 +118,10 @@ public class EventTrackResource extends IcarusResource {
try
{
try
{
toSend
.
put
(
"EventName"
,
eventName
);
toSend
.
put
(
EVENT_NAME_KEY
,
eventName
);
toSend
.
put
(
"EventCategory"
,
eventCategory
);
toSend
.
put
(
EVENT_CATEGORY_KEY
,
eventCategory
.
name
().
toLowerCase
()
);
toSend
.
put
(
"EventLabel"
,
eventLabel
+
"_TalkBack"
+(
accessibilityEnabled
?
"_ON"
:
"_OFF"
));
toSend
.
put
(
EVENT_LABEL_KEY
,
eventLabel
.
name
().
toLowerCase
()
+
"_TalkBack"
+(
accessibilityEnabled
?
"_ON"
:
"_OFF"
));
toSend
.
put
(
"EventContext"
,
eventContextJSONObject
);
toSend
.
put
(
EVENT_CONTEXT_KEY
,
eventContextJSONObject
);
}
catch
(
JSONException
jsonException
){
}
catch
(
JSONException
jsonException
){
...
...
IcarusAndroid/icarus/src/main/java/framework/everywaretechnologies/it/icarus/Icarus.java
View file @
f412b4ed
...
@@ -40,6 +40,25 @@ public class Icarus {
...
@@ -40,6 +40,25 @@ public class Icarus {
private
final
static
String
ICARUS_URL
=
"https://webdev.ewlab.di.unimi.it/icarus/str"
;
private
final
static
String
ICARUS_URL
=
"https://webdev.ewlab.di.unimi.it/icarus/str"
;
//---------------- JSON KEYS ---------------------
private
final
static
String
UTC_KEY
=
"utc"
;
private
final
static
String
USER_KEY
=
"user"
;
private
final
static
String
LANG_KEY
=
"lang"
;
private
final
static
String
ICARUS_VERSION_KEY
=
"icarusversion"
;
private
final
static
String
APP_NAME_KEY
=
"appname"
;
private
final
static
String
APP_VERSION_KEY
=
"appversion"
;
private
final
static
String
OS_VERSION_KEY
=
"osversion"
;
private
final
static
String
PLATFORM_KEY
=
"platform"
;
private
final
static
String
DEVICE_KEY
=
"device"
;
private
final
static
String
UUID_KEY
=
"uuid"
;
private
final
static
String
TALKBACK_KEY
=
"talkback"
;
private
final
static
String
DEBUG_KEY
=
"debug"
;
private
final
static
String
TIMESTAMP_KEY
=
"timestamp"
;
private
final
static
String
APP_DATA_KEY
=
"appdata"
;
private
final
static
String
USER_DATA_KEY
=
"userdata"
;
//------------------------------------------
private
static
final
Icarus
ourInstance
=
new
Icarus
();
private
static
final
Icarus
ourInstance
=
new
Icarus
();
private
Queue
<
JSONObject
>
pendingResources
;
//FIFO
private
Queue
<
JSONObject
>
pendingResources
;
//FIFO
private
Lock
pendingResourceLock
;
private
Lock
pendingResourceLock
;
...
@@ -190,8 +209,8 @@ public class Icarus {
...
@@ -190,8 +209,8 @@ public class Icarus {
long
userTime
=
utcTime
+
timeOffsetBetweenMeAndGMT
;
long
userTime
=
utcTime
+
timeOffsetBetweenMeAndGMT
;
JSONObject
timeJSON
=
new
JSONObject
();
JSONObject
timeJSON
=
new
JSONObject
();
timeJSON
.
put
(
"utc"
,
utcTime
);
timeJSON
.
put
(
UTC_KEY
,
utcTime
);
timeJSON
.
put
(
"user"
,
userTime
);
timeJSON
.
put
(
USER_KEY
,
userTime
);
//---------------------- APP JSON ---------------------
//---------------------- APP JSON ---------------------
...
@@ -238,22 +257,22 @@ public class Icarus {
...
@@ -238,22 +257,22 @@ public class Icarus {
}
}
JSONObject
appInfoJSON
=
new
JSONObject
();
JSONObject
appInfoJSON
=
new
JSONObject
();
appInfoJSON
.
put
(
"lang"
,
Locale
.
getDefault
().
getLanguage
());
appInfoJSON
.
put
(
LANG_KEY
,
Locale
.
getDefault
().
getLanguage
());
appInfoJSON
.
put
(
"icarusversion"
,
"Icarus:"
+
curContext
.
getResources
().
getInteger
(
R
.
integer
.
lib_version
));
appInfoJSON
.
put
(
ICARUS_VERSION_KEY
,
"Icarus:"
+
curContext
.
getResources
().
getInteger
(
R
.
integer
.
lib_version
));
appInfoJSON
.
put
(
"appname"
,
appName
.
toString
());
appInfoJSON
.
put
(
APP_NAME_KEY
,
appName
.
toString
());
appInfoJSON
.
put
(
"appversion"
,
clientAppVersion
);
appInfoJSON
.
put
(
APP_VERSION_KEY
,
clientAppVersion
);
appInfoJSON
.
put
(
"osversion"
,
Build
.
VERSION
.
SDK_INT
);
appInfoJSON
.
put
(
OS_VERSION_KEY
,
Build
.
VERSION
.
SDK_INT
);
appInfoJSON
.
put
(
"platform"
,
"android"
);
appInfoJSON
.
put
(
PLATFORM_KEY
,
"android"
);
appInfoJSON
.
put
(
"device"
,
getDeviceName
());
appInfoJSON
.
put
(
DEVICE_KEY
,
getDeviceName
());
appInfoJSON
.
put
(
"uuid"
,
uuid
);
appInfoJSON
.
put
(
UUID_KEY
,
uuid
);
appInfoJSON
.
put
(
"talkback"
,
accessibilityEnabled
);
appInfoJSON
.
put
(
TALKBACK_KEY
,
accessibilityEnabled
);
//---------------- GENERAL JSON --------------------
//---------------- GENERAL JSON --------------------
toSend
.
put
(
"debug"
,
debug
);
toSend
.
put
(
DEBUG_KEY
,
debug
);
toSend
.
put
(
"timestamp"
,
timeJSON
);
toSend
.
put
(
TIMESTAMP_KEY
,
timeJSON
);
toSend
.
put
(
"appdata"
,
appInfoJSON
);
toSend
.
put
(
APP_DATA_KEY
,
appInfoJSON
);
toSend
.
put
(
"userdata"
,
userData
);
toSend
.
put
(
USER_DATA_KEY
,
userData
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
IcarusAndroid/icarus/src/main/java/framework/everywaretechnologies/it/icarus/UserSettingsResource.java
View file @
f412b4ed
This diff is collapsed.
Click to expand it.
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