Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christof Wolke
BIDL
Commits
127949bc
Commit
127949bc
authored
Aug 29, 2016
by
Christof Wolke
Browse files
Display all apps from currentEvent
parent
1d96eec0
Changes
12
Hide whitespace changes
Inline
Side-by-side
BIDL/BIDL/app/src/main/AndroidManifest.xml
View file @
127949bc
...
...
@@ -2,16 +2,13 @@
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"de.uni_oldenburg.bidl"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<application
android:name=
"
de.uni_oldenburg.bidl
.AppClass"
android:name=
".AppClass"
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
...
...
@@ -21,7 +18,7 @@
<!--
Don't increase version on every single DB model change, use Rush_debug instead (see below).
de.uni_oldenburg.bidl.AppClass also contains code to allow dropping the database
-->
-->
<meta-data
android:name=
"Rush_classes_package"
android:value=
"de.uni_oldenburg.bidl.classes"
/>
...
...
@@ -47,21 +44,37 @@
android:value=
"false"
/>
<activity
android:name=
"
de.uni_oldenburg.bidl.bas
e_view.MainActivity"
android:label=
"Bidl
"
android:name=
"
.hom
e_view.MainActivity"
android:label=
"@string/app_name
"
android:screenOrientation=
"sensorPortrait"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
"de.uni_oldenburg.bidl.guest_view.LoginActivity"
android:screenOrientation=
"sensorPortrait"
/>
<activity
android:name=
".guest_view.LoginActivity"
android:screenOrientation=
"sensorPortrait"
/>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
</intent-filter>
<activity
android:name=
"de.uni_oldenburg.bidl.guest_view.RegisterActivity"
<activity
android:name=
".guest_view.RegisterActivity"
android:parentActivityName=
".guest_view.LoginActivity"
android:screenOrientation=
"sensorPortrait"
>
<meta-data
android:name=
"android.support.PARENT_ACTIVITY"
android:value=
".guest_view.LoginActivity"
/>
</activity>
<activity
android:name=
".member_view.ForumActivity"
android:screenOrientation=
"sensorPortrait"
/>
<activity
android:name=
".member_view.FeedbackActivity"
android:screenOrientation=
"sensorPortrait"
/>
</application>
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/guest_view/LoginActivity.java
View file @
127949bc
...
...
@@ -16,7 +16,7 @@ import com.estimote.sdk.SystemRequirementsChecker;
import
classes.LocalStorage
;
import
classes.User
;
import
de.uni_oldenburg.bidl.R
;
import
de.uni_oldenburg.bidl.
bas
e_view.MainActivity
;
import
de.uni_oldenburg.bidl.
hom
e_view.MainActivity
;
import
services.servercommunication.NetworkService
;
public
class
LoginActivity
extends
AppCompatActivity
{
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/guest_view/RegisterActivity.java
View file @
127949bc
...
...
@@ -10,7 +10,7 @@ import android.widget.TextView;
import
android.widget.Toast
;
import
de.uni_oldenburg.bidl.R
;
import
de.uni_oldenburg.bidl.
bas
e_view.MainActivity
;
import
de.uni_oldenburg.bidl.
hom
e_view.MainActivity
;
import
services.servercommunication.NetworkService
;
public
class
RegisterActivity
extends
AppCompatActivity
{
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/
bas
e_view/MainActivity.java
→
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/
hom
e_view/MainActivity.java
View file @
127949bc
package
de.uni_oldenburg.bidl.
bas
e_view
;
package
de.uni_oldenburg.bidl.
hom
e_view
;
import
android.app.ProgressDialog
;
import
android.bluetooth.BluetoothAdapter
;
import
android.content.Intent
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.ArrayAdapter
;
import
android.widget.GridView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
...
...
@@ -14,6 +18,7 @@ import com.estimote.sdk.BeaconManager;
import
com.estimote.sdk.Region
;
import
com.estimote.sdk.SystemRequirementsChecker
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
...
...
@@ -32,19 +37,27 @@ public class MainActivity extends AppCompatActivity {
/** Soll nach Beacons gesucht werden? **/
private
static
final
Boolean
RANGING
=
true
;
/** Package, wo die apps angelegt werden **/
private
static
final
String
appPackage
=
"de.uni_oldenburg.bidl.member_view."
;
/** Estimote Beacon UUID **/
private
static
UUID
PROXIMITY_UUID
;
/** GUI **/
private
TextView
beaconID
;
private
GridView
grid
;
private
TextView
noBeaconTV
;
/** values **/
private
Region
region
;
private
BeaconManager
beaconManager
;
private
Beacon
nearestBeacon
;
private
Event
event
;
private
ArrayList
<
String
>
apps
=
new
ArrayList
<>();
private
ArrayAdapter
<
String
>
adapter
;
protected
LocalStorage
localStorage
;
private
ProgressDialog
progress
;
...
...
@@ -53,7 +66,11 @@ public class MainActivity extends AppCompatActivity {
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
/** init **/
beaconID
=
(
TextView
)
findViewById
(
R
.
id
.
BeaconID
);
adapter
=
new
ArrayAdapter
<>(
MainActivity
.
this
,
R
.
layout
.
grid_item
,
R
.
id
.
grid_text
,
apps
);
grid
=
(
GridView
)
findViewById
(
R
.
id
.
mainActivityGrid
);
noBeaconTV
=
(
TextView
)
findViewById
(
R
.
id
.
noBeaconTV
);
grid
.
setAdapter
(
adapter
);
PROXIMITY_UUID
=
UUID
.
fromString
(
getResources
().
getString
(
R
.
string
.
ESTIMOTE_PROXIMITY_UUID
));
this
.
localStorage
=
new
LocalStorage
(
this
);
...
...
@@ -66,26 +83,68 @@ public class MainActivity extends AppCompatActivity {
/** region is the hole university --> all beacons have the same proximity_UUID **/
region
=
new
Region
(
"ranged region"
,
PROXIMITY_UUID
,
null
,
null
);
beaconManager
=
new
BeaconManager
(
this
);
beaconManager
.
setForegroundScanPeriod
(
4000
,
1000
);
setProgressDialog
();
/**
* Start ranging for beacons.
**/
startRanging
();
/**
* open activity based on the griditem, displayed at the MainActivity
*/
makeGridItemClickable
();
}
private
void
makeGridItemClickable
()
{
grid
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
adapterView
,
View
view
,
int
position
,
long
id
)
{
String
appName
=
(
String
)
adapterView
.
getItemAtPosition
(
position
);
Class
<?>
c
=
null
;
try
{
c
=
Class
.
forName
(
appPackage
+
appName
+
"Activity"
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
Intent
intent
=
new
Intent
(
getApplicationContext
(),
c
).
putExtra
(
"appName"
,
appName
);
startActivity
(
intent
);
}
});
}
private
void
setProgressDialog
()
{
progress
=
new
ProgressDialog
(
this
);
progress
.
setTitle
(
"Loading"
);
progress
.
setMessage
(
"Wait while searching for Beacons..."
);
progress
.
show
();
}
private
void
startRanging
()
{
if
(
RANGING
&&
isBluetoothAvailable
()){
beaconManager
.
setRangingListener
(
new
BeaconManager
.
RangingListener
()
{
@Override
public
void
onBeaconsDiscovered
(
Region
region
,
List
<
Beacon
>
list
)
{
noBeaconTV
.
setVisibility
(
View
.
INVISIBLE
);
if
(!
list
.
isEmpty
()
&&
!
list
.
get
(
0
).
equals
(
nearestBeacon
)){
nearestBeacon
=
list
.
get
(
0
);
getEventFromServer
(
nearestBeacon
);
}
if
(
list
.
isEmpty
()){
showMessage
(
getResources
().
getString
(
R
.
string
.
noBeaconFound
));
progress
.
dismiss
();
noBeaconTV
.
setText
(
R
.
string
.
noBeaconFound
);
noBeaconTV
.
setVisibility
(
View
.
VISIBLE
);
}
}
});
}
}
private
void
getEventFromServer
(
Beacon
nearestBeacon
)
{
...
...
@@ -95,13 +154,18 @@ public class MainActivity extends AppCompatActivity {
NetworkService
.
getEvent
(
uud
,
major
,
minor
,
new
NetworkService
.
RequestGetEventHandler
()
{
@Override
public
void
done
(
Event
event
)
{
public
void
done
(
final
Event
event
)
{
if
(
event
!=
null
){
//TODO: event.getApps und die Liste dem gridadapter übergeben und die Main View verändern.
Log
.
d
(
TAG
,
"TEST: "
+
event
.
getEventId
()+
" "
+
event
.
getName
()+
" "
+
event
.
getApps
());
MainActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
setTitle
(
event
.
getName
());
updateData
(
event
.
getApps
());
}
});
}
else
{
progress
.
dismiss
();
showMessage
(
getResources
().
getString
(
R
.
string
.
noCurrentEvent
));
}
...
...
@@ -110,11 +174,22 @@ public class MainActivity extends AppCompatActivity {
}
private
void
updateData
(
ArrayList
<
String
>
apps
)
{
progress
.
dismiss
();
adapter
.
clear
();
if
(
apps
!=
null
){
for
(
String
app:
apps
){
adapter
.
insert
(
app
,
adapter
.
getCount
());
}
}
adapter
.
notifyDataSetChanged
();
}
@Override
protected
void
onResume
(){
super
.
onResume
();
// is Bluetooth on, is Location on, etc.
//TODO: only check if Bluethooth is on.
SystemRequirementsChecker
.
checkWithDefaultDialogs
(
this
);
// Start ranging for beacons, when the activity appears on the screen
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/member_view/FeedbackActivity.java
0 → 100644
View file @
127949bc
package
de.uni_oldenburg.bidl.member_view
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
de.uni_oldenburg.bidl.R
;
public
class
FeedbackActivity
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_feedback
);
setTitle
(
getIntent
().
getStringExtra
(
"appName"
));
}
}
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/member_view/ForumActivity.java
0 → 100644
View file @
127949bc
package
de.uni_oldenburg.bidl.member_view
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
de.uni_oldenburg.bidl.R
;
public
class
ForumActivity
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_forum
);
setTitle
(
getIntent
().
getStringExtra
(
"appName"
));
}
}
BIDL/BIDL/app/src/main/res/layout/activity_feedback.xml
0 → 100644
View file @
127949bc
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingBottom=
"@dimen/activity_vertical_margin"
android:paddingLeft=
"@dimen/activity_horizontal_margin"
android:paddingRight=
"@dimen/activity_horizontal_margin"
android:paddingTop=
"@dimen/activity_vertical_margin"
tools:context=
"de.uni_oldenburg.bidl.member_view.FeedbackActivity"
>
</RelativeLayout>
BIDL/BIDL/app/src/main/res/layout/activity_forum.xml
0 → 100644
View file @
127949bc
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingBottom=
"@dimen/activity_vertical_margin"
android:paddingLeft=
"@dimen/activity_horizontal_margin"
android:paddingRight=
"@dimen/activity_horizontal_margin"
android:paddingTop=
"@dimen/activity_vertical_margin"
tools:context=
"de.uni_oldenburg.bidl.member_view.ForumActivity"
>
</RelativeLayout>
BIDL/BIDL/app/src/main/res/layout/activity_main.xml
View file @
127949bc
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/activity_main"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
"de.uni_oldenburg.bidl.bidl.app.base_view.MainActivity"
>
tools:context=
"de.uni_oldenburg.bidl.home_view.MainActivity"
>
<TextView
android:id=
"@+id/BeaconID"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Hello World!"
app:layout_constraintBottom_toBottomOf=
"@+id/activity_main"
app:layout_constraintLeft_toLeftOf=
"@+id/activity_main"
app:layout_constraintRight_toRightOf=
"@+id/activity_main"
app:layout_constraintTop_toTopOf=
"@+id/activity_main"
/>
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:id=
"@+id/noBeaconTV"
android:gravity=
"center"
android:visibility=
"invisible"
/>
<GridView
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:gravity=
"center"
android:layout_margin=
"5dp"
android:stretchMode=
"columnWidth"
android:id=
"@+id/mainActivityGrid"
android:numColumns=
"2"
android:focusable=
"true"
></GridView>
</android.support.constraint.ConstraintLayout>
BIDL/BIDL/app/src/main/res/layout/grid_item.xml
0 → 100644
View file @
127949bc
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<TextView
android:id=
"@+id/grid_text"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/grey"
android:gravity=
"center"
android:textSize=
"20sp"
android:layout_margin=
"10dp"
android:padding=
"20dp"
/>
</LinearLayout>
\ No newline at end of file
BIDL/BIDL/app/src/main/res/values/strings.xml
View file @
127949bc
<resources>
<string
name=
"app_name"
>
BIDL
</string>
<string
name=
"app_name"
>
Bidl
</string>
<!-- Splash Activity !-->
<string
name=
"noBeaconFound"
>
Kein Beacon in der Nähe!
</string>
...
...
@@ -34,5 +34,4 @@
<string
name=
"register_response_noconnection"
>
Es konnte keine Verbindung zum Server hergestellt werden!
</string>
</resources>
BIDL/BIDL/build.gradle
View file @
127949bc
...
...
@@ -5,7 +5,7 @@ buildscript {
jcenter
()
}
dependencies
{
classpath
'com.android.tools.build:gradle:2.
2.0-alpha6
'
classpath
'com.android.tools.build:gradle:2.
1.3
'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
...
...
Write
Preview
Supports
Markdown
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