Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
BIDL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Christof Wolke
BIDL
Commits
75c20ecf
Commit
75c20ecf
authored
Aug 23, 2016
by
Christof Wolke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get the current event
parent
63d749f9
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
519 additions
and
8 deletions
+519
-8
BIDL/BIDL/.idea/misc.xml
BIDL/BIDL/.idea/misc.xml
+1
-1
BIDL/BIDL/app/src/main/java/classes/AppContainer.java
BIDL/BIDL/app/src/main/java/classes/AppContainer.java
+75
-0
BIDL/BIDL/app/src/main/java/classes/Comment.java
BIDL/BIDL/app/src/main/java/classes/Comment.java
+64
-0
BIDL/BIDL/app/src/main/java/classes/Event.java
BIDL/BIDL/app/src/main/java/classes/Event.java
+62
-0
BIDL/BIDL/app/src/main/java/classes/Feedback.java
BIDL/BIDL/app/src/main/java/classes/Feedback.java
+49
-0
BIDL/BIDL/app/src/main/java/classes/Forum.java
BIDL/BIDL/app/src/main/java/classes/Forum.java
+52
-0
BIDL/BIDL/app/src/main/java/classes/Materials.java
BIDL/BIDL/app/src/main/java/classes/Materials.java
+62
-0
BIDL/BIDL/app/src/main/java/classes/User.java
BIDL/BIDL/app/src/main/java/classes/User.java
+1
-1
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/base_view/MainActivity.java
...in/java/de/uni_oldenburg/bidl/base_view/MainActivity.java
+89
-4
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/base_view/SplashActivity.java
.../java/de/uni_oldenburg/bidl/base_view/SplashActivity.java
+3
-1
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/guest_view/LoginActivity.java
.../java/de/uni_oldenburg/bidl/guest_view/LoginActivity.java
+7
-0
BIDL/BIDL/app/src/main/java/services/servercommunication/NetworkService.java
...ain/java/services/servercommunication/NetworkService.java
+49
-0
BIDL/BIDL/app/src/main/java/services/servercommunication/REST.java
.../app/src/main/java/services/servercommunication/REST.java
+5
-1
No files found.
BIDL/BIDL/.idea/misc.xml
View file @
75c20ecf
...
...
@@ -37,7 +37,7 @@
<ConfirmationsSetting
value=
"0"
id=
"Add"
/>
<ConfirmationsSetting
value=
"0"
id=
"Remove"
/>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8
"
default=
"true"
assert-keyword=
"true"
jdk-15=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
default=
"true"
assert-keyword=
"true"
jdk-15=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
BIDL/BIDL/app/src/main/java/classes/AppContainer.java
0 → 100644
View file @
75c20ecf
package
classes
;
import
com.bluelinelabs.logansquare.annotation.JsonField
;
import
com.bluelinelabs.logansquare.annotation.JsonObject
;
/**
* Created by Christof on 23.08.2016.
*/
@JsonObject
public
class
AppContainer
{
@JsonField
(
name
=
"id"
)
private
int
appContainerId
;
@JsonField
(
name
=
"feedback"
)
private
Feedback
feedback
;
@JsonField
(
name
=
"forum"
)
private
Forum
forum
;
@JsonField
(
name
=
"materials"
)
private
Materials
materials
;
public
AppContainer
()
{
}
public
AppContainer
(
int
appContainerId
,
Feedback
feedback
,
Forum
forum
,
Materials
materials
)
{
this
.
appContainerId
=
appContainerId
;
this
.
feedback
=
feedback
;
this
.
forum
=
forum
;
this
.
materials
=
materials
;
}
public
int
getAppContainerId
()
{
return
appContainerId
;
}
public
void
setAppContainerId
(
int
appContainerId
)
{
this
.
appContainerId
=
appContainerId
;
}
public
Feedback
getFeedback
()
{
return
feedback
;
}
public
void
setFeedback
(
Feedback
feedback
)
{
this
.
feedback
=
feedback
;
}
public
Forum
getForum
()
{
return
forum
;
}
public
void
setForum
(
Forum
forum
)
{
this
.
forum
=
forum
;
}
public
Materials
getMaterials
()
{
return
materials
;
}
public
void
setMaterials
(
Materials
materials
)
{
this
.
materials
=
materials
;
}
@Override
public
String
toString
()
{
return
"AppContainer{"
+
"appContainerId="
+
appContainerId
+
", feedback="
+
feedback
+
", forum="
+
forum
+
", materials="
+
materials
+
'}'
;
}
}
BIDL/BIDL/app/src/main/java/classes/Comment.java
0 → 100644
View file @
75c20ecf
package
classes
;
import
com.bluelinelabs.logansquare.annotation.JsonField
;
import
com.bluelinelabs.logansquare.annotation.JsonObject
;
import
java.util.Date
;
/**
* Created by Christof on 23.08.2016.
*/
@JsonObject
public
class
Comment
{
@JsonField
(
name
=
"id"
)
private
int
commentID
;
@JsonField
(
name
=
"text"
)
private
String
text
;
@JsonField
(
name
=
"timestamp"
)
private
Date
timestamp
;
public
Comment
()
{
}
public
Comment
(
int
commentID
,
String
text
,
Date
timestamp
)
{
this
.
commentID
=
commentID
;
this
.
text
=
text
;
this
.
timestamp
=
timestamp
;
}
public
int
getCommentID
()
{
return
commentID
;
}
public
void
setCommentID
(
int
commentID
)
{
this
.
commentID
=
commentID
;
}
public
String
getText
()
{
return
text
;
}
public
void
setText
(
String
text
)
{
this
.
text
=
text
;
}
public
Date
getTimestamp
()
{
return
timestamp
;
}
public
void
setTimestamp
(
Date
timestamp
)
{
this
.
timestamp
=
timestamp
;
}
@Override
public
String
toString
()
{
return
"Comment{"
+
"commentID="
+
commentID
+
", text='"
+
text
+
'\''
+
", timestamp="
+
timestamp
+
'}'
;
}
}
BIDL/BIDL/app/src/main/java/classes/Event.java
0 → 100644
View file @
75c20ecf
package
classes
;
import
com.bluelinelabs.logansquare.annotation.JsonField
;
import
com.bluelinelabs.logansquare.annotation.JsonObject
;
/**
* Created by Christof on 23.08.2016.
*/
@JsonObject
public
class
Event
{
@JsonField
(
name
=
"id"
)
private
int
eventId
;
@JsonField
(
name
=
"name"
)
private
String
name
;
@JsonField
(
name
=
"appContainer"
)
private
AppContainer
appContainer
;
public
Event
()
{
}
public
Event
(
int
eventId
,
String
name
,
AppContainer
appContainer
)
{
this
.
eventId
=
eventId
;
this
.
name
=
name
;
this
.
appContainer
=
appContainer
;
}
public
int
getEventId
()
{
return
eventId
;
}
public
void
setEventId
(
int
eventId
)
{
this
.
eventId
=
eventId
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
AppContainer
getAppContainer
()
{
return
appContainer
;
}
public
void
setAppContainer
(
AppContainer
appContainer
)
{
this
.
appContainer
=
appContainer
;
}
@Override
public
String
toString
()
{
return
"Event{"
+
"eventId="
+
eventId
+
", name='"
+
name
+
'\''
+
", appContainer="
+
appContainer
+
'}'
;
}
}
BIDL/BIDL/app/src/main/java/classes/Feedback.java
0 → 100644
View file @
75c20ecf
package
classes
;
import
com.bluelinelabs.logansquare.annotation.JsonField
;
import
com.bluelinelabs.logansquare.annotation.JsonObject
;
/**
* Created by Christof on 23.08.2016.
*/
@JsonObject
public
class
Feedback
{
@JsonField
(
name
=
"id"
)
private
int
feedbackId
;
@JsonField
(
name
=
"title"
)
private
String
title
;
public
Feedback
()
{
}
public
Feedback
(
int
feedbackId
,
String
title
)
{
this
.
feedbackId
=
feedbackId
;
this
.
title
=
title
;
}
public
int
getFeedbackId
()
{
return
feedbackId
;
}
public
void
setFeedbackId
(
int
feedbackId
)
{
this
.
feedbackId
=
feedbackId
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
@Override
public
String
toString
()
{
return
"Feedback{"
+
"feedbackId="
+
feedbackId
+
", title='"
+
title
+
'\''
+
'}'
;
}
}
BIDL/BIDL/app/src/main/java/classes/Forum.java
0 → 100644
View file @
75c20ecf
package
classes
;
import
com.bluelinelabs.logansquare.annotation.JsonField
;
import
com.bluelinelabs.logansquare.annotation.JsonObject
;
import
java.util.ArrayList
;
/**
* Created by Christof on 23.08.2016.
*/
@JsonObject
public
class
Forum
{
@JsonField
(
name
=
"id"
)
private
int
forumId
;
@JsonField
(
name
=
"comments"
)
private
ArrayList
<
Comment
>
comments
;
public
Forum
(){
}
public
Forum
(
int
forumId
,
ArrayList
<
Comment
>
comments
)
{
this
.
forumId
=
forumId
;
this
.
comments
=
comments
;
}
public
int
getForumId
()
{
return
forumId
;
}
public
void
setForumId
(
int
forumId
)
{
this
.
forumId
=
forumId
;
}
public
ArrayList
<
Comment
>
getComments
()
{
return
comments
;
}
public
void
setComments
(
ArrayList
<
Comment
>
comments
)
{
this
.
comments
=
comments
;
}
@Override
public
String
toString
()
{
return
"Forum{"
+
"forumId="
+
forumId
+
", comments="
+
comments
+
'}'
;
}
}
BIDL/BIDL/app/src/main/java/classes/Materials.java
0 → 100644
View file @
75c20ecf
package
classes
;
import
com.bluelinelabs.logansquare.annotation.JsonField
;
import
com.bluelinelabs.logansquare.annotation.JsonObject
;
/**
* Created by Christof on 23.08.2016.
*/
@JsonObject
public
class
Materials
{
@JsonField
(
name
=
"id"
)
private
int
materialsId
;
@JsonField
(
name
=
"title"
)
private
String
title
;
@JsonField
(
name
=
"url"
)
private
String
url
;
public
Materials
()
{
}
public
Materials
(
int
materialsId
,
String
title
,
String
url
)
{
this
.
materialsId
=
materialsId
;
this
.
title
=
title
;
this
.
url
=
url
;
}
public
int
getMaterialsId
()
{
return
materialsId
;
}
public
void
setMaterialsId
(
int
materialsId
)
{
this
.
materialsId
=
materialsId
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
@Override
public
String
toString
()
{
return
"Materials{"
+
"materialsId="
+
materialsId
+
", title='"
+
title
+
'\''
+
", url='"
+
url
+
'\''
+
'}'
;
}
}
BIDL/BIDL/app/src/main/java/classes/User.java
View file @
75c20ecf
...
...
@@ -5,7 +5,7 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* Represent a User and al important informations
* Represent a User and al
l
important informations
* Created by Christof on 04.08.2016.
*/
@JsonObject
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/base_view/MainActivity.java
View file @
75c20ecf
package
de.uni_oldenburg.bidl.base_view
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.os.Handler
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.estimote.sdk.Beacon
;
import
com.estimote.sdk.BeaconManager
;
import
com.estimote.sdk.Region
;
import
com.estimote.sdk.SystemRequirementsChecker
;
import
java.util.List
;
import
java.util.UUID
;
import
classes.Event
;
import
de.uni_oldenburg.bidl.R
;
import
de.uni_oldenburg.bidl.guest_view.LoginActivity
;
import
services.servercommunication.NetworkService
;
import
static
com
.
estimote
.
sdk
.
repackaged
.
gson_v2_3_1
.
com
.
google
.
gson
.
internal
.
UnsafeAllocator
.
create
;
import
static
de
.
uni_oldenburg
.
bidl
.
R
.
string
.
noBeaconFound
;
public
class
MainActivity
extends
AppCompatActivity
{
/** Tag for Logging **/
private
static
final
String
TAG
=
MainActivity
.
class
.
getSimpleName
();
/** Estimote Beacon UUID **/
private
static
final
UUID
PROXIMITY_UUID
=
UUID
.
fromString
(
"B9407F30-F5F8-466E-AFF9-25556B57FE6D"
);
/** GUI **/
private
TextView
beaconID
;
/** values **/
boolean
doubleBackToExitPressedOnce
=
false
;
private
Region
region
;
private
BeaconManager
beaconManager
;
private
Beacon
nearestBeacon
;
...
...
@@ -32,11 +49,75 @@ public class MainActivity extends AppCompatActivity {
/** init **/
beaconID
=
(
TextView
)
findViewById
(
R
.
id
.
BeaconID
);
/**
* Start ranging for beacons.
**/
beaconManager
=
new
BeaconManager
(
this
);
/** region is the hole university --> all beacons have the same proximity_UUID **/
region
=
new
Region
(
"ranged region"
,
PROXIMITY_UUID
,
null
,
null
);
beaconManager
.
setRangingListener
(
new
BeaconManager
.
RangingListener
()
{
@Override
public
void
onBeaconsDiscovered
(
Region
region
,
List
<
Beacon
>
list
)
{
if
(!
list
.
isEmpty
()
&&
!
list
.
get
(
0
).
equals
(
nearestBeacon
)){
// TODO: 30.07.2016 React, when the user is nearer to another Beacon.
nearestBeacon
=
list
.
get
(
0
);
getEventFromServer
(
nearestBeacon
);
}
if
(
list
.
isEmpty
()){
showMessage
();
}
}
});
}
private
void
getEventFromServer
(
Beacon
nearestBeacon
)
{
String
uud
=
nearestBeacon
.
getProximityUUID
().
toString
().
toUpperCase
();
int
major
=
nearestBeacon
.
getMajor
();
int
minor
=
nearestBeacon
.
getMinor
();
NetworkService
.
getEvent
(
uud
,
major
,
minor
,
new
NetworkService
.
RequestGetEventHandler
()
{
@Override
public
void
done
(
final
Event
event
)
{
MainActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
beaconID
.
setText
(
event
.
getName
());
}
});
}
});
}
@Override
protected
void
onResume
(){
super
.
onResume
();
// is Bluetooth on, is Location on, etc.
SystemRequirementsChecker
.
checkWithDefaultDialogs
(
this
);
// Start ranging for beacons, when the activity appears on the screen
beaconManager
.
connect
(
new
BeaconManager
.
ServiceReadyCallback
()
{
@Override
public
void
onServiceReady
()
{
beaconManager
.
startRanging
(
region
);
}
});
}
/**
* Ranging ist stopped, if the Activity disappears.
*/
@Override
public
void
onPause
(){
beaconManager
.
stopRanging
(
region
);
super
.
onPause
();
}
@Override
public
void
onBackPressed
()
{
if
(
doubleBackToExitPressedOnce
)
{
...
...
@@ -57,4 +138,8 @@ public class MainActivity extends AppCompatActivity {
}
},
2000
);
}
private
void
showMessage
()
{
Toast
.
makeText
(
this
,
noBeaconFound
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/base_view/SplashActivity.java
View file @
75c20ecf
package
de.uni_oldenburg.bidl.base_view
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.view.View
;
...
...
@@ -41,6 +42,7 @@ public class SplashActivity extends AppCompatActivity {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -73,8 +75,8 @@ public class SplashActivity extends AppCompatActivity {
toLoginActivity
();
// TODO: 30.07.2016 save the Beacon in the database and overwrite the DB, when the nearestBeacon != the saved beacon.
}
if
(
list
.
isEmpty
()){
// TODO: 30.07.2016 toScrenn beacon not found...
showMessage
();
toLoginActivity
();
}
}
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/guest_view/LoginActivity.java
View file @
75c20ecf
...
...
@@ -11,6 +11,8 @@ import android.widget.ImageView;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.estimote.sdk.SystemRequirementsChecker
;
import
classes.User
;
import
de.uni_oldenburg.bidl.R
;
import
de.uni_oldenburg.bidl.base_view.MainActivity
;
...
...
@@ -97,6 +99,11 @@ public class LoginActivity extends AppCompatActivity {
});
}
protected
void
onResume
(){
super
.
onResume
();
//is Bluetooth on, is Location on, etc.
SystemRequirementsChecker
.
checkWithDefaultDialogs
(
this
);
}
@Override
public
void
onBackPressed
()
{
super
.
onBackPressed
();
...
...
BIDL/BIDL/app/src/main/java/services/servercommunication/NetworkService.java
View file @
75c20ecf
...
...
@@ -12,6 +12,7 @@ import com.squareup.okhttp.Response;
import
java.io.IOException
;
import
java.util.concurrent.TimeUnit
;
import
classes.Event
;
import
classes.StatusResponse
;
import
classes.User
;
...
...
@@ -127,4 +128,52 @@ public abstract class NetworkService {
public
interface
RequestRegisterHandler
{
void
done
(
String
statusResponse
);
}
public
static
void
getEvent
(
String
uud
,
int
major
,
int
minor
,
final
RequestGetEventHandler
handler
){
okHttpClient
.
setReadTimeout
(
15
,
TimeUnit
.
SECONDS
);
/* OkHttpClient
Request body mit POST params
*/
RequestBody
requestBody
=
new
FormEncodingBuilder
()
.
add
(
"uud"
,
uud
)
.
add
(
"major"
,
String
.
valueOf
(
major
))
.
add
(
"minor"
,
String
.
valueOf
(
minor
))
.
build
();
/* add body to POST-request */
Request
req
=
new
Request
.
Builder
()
.
url
(
REST
.
SPRING_GETEVENT
)
.
post
(
requestBody
)
.
build
();
/* Server call preparation */
Call
call
=
okHttpClient
.
newCall
(
req
);
/* Async call */
call
.
enqueue
(
new
Callback
()
{
@Override
public
void
onFailure
(
Request
request
,
IOException
e
)
{
handler
.
done
(
null
);
e
.
printStackTrace
();
}
@Override
public
void
onResponse
(
Response
response
)
throws
IOException
{
try
{
/* Server response parsing */
if
(
response
.
isSuccessful
()){
String
responseString
=
response
.
body
().
string
();
Event
event
=
LoganSquare
.
parse
(
responseString
,
Event
.
class
);
handler
.
done
(
event
);
}
}
catch
(
IOException
e
){
handler
.
done
(
null
);
e
.
printStackTrace
();
}
}
});
}