Commit 0f4c2c74 authored by Christof Wolke's avatar Christof Wolke

siehe vorherigen commit

parent d2685218
......@@ -53,7 +53,7 @@ dependencies {
// Import OkHttp library (https://github.com/square/okhttp)
compile 'com.squareup.okhttp:okhttp:2.7.1'
// Import RushOrm library (https://github.com/Stuart-campbell/RushOrm)
compile 'co.uk.rushorm:rushandroid:1.2.0'
compile 'co.uk.rushorm:rushandroid:1.1.11'
// Import GifImageView library (https://github.com/felipecsl/GifImageView)
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
compile 'com.android.support:appcompat-v7:24.1.1'
......
package de.uni_oldenburg.bidl.base_view;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
......@@ -13,14 +14,18 @@ import com.estimote.sdk.BeaconManager;
import com.estimote.sdk.Region;
import com.estimote.sdk.SystemRequirementsChecker;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import classes.Event;
import classes.LocalStorage;
import classes.User;
import classes.apps.AppContainer;
import classes.apps.Feedback;
import classes.apps.Forum;
import de.uni_oldenburg.bidl.R;
import de.uni_oldenburg.bidl.guest_view.LoginActivity;
import services.db.DBHelper;
import services.servercommunication.NetworkService;
......@@ -33,7 +38,7 @@ public class MainActivity extends AppCompatActivity {
private static final Boolean RANGING = true;
/** Estimote Beacon UUID **/
private static final UUID PROXIMITY_UUID = UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D");
private static UUID PROXIMITY_UUID;
/** GUI **/
private TextView beaconID;
......@@ -54,6 +59,7 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main);
/** init **/
beaconID = (TextView) findViewById(R.id.BeaconID);
PROXIMITY_UUID = UUID.fromString(getResources().getString(R.string.ESTIMOTE_PROXIMITY_UUID));
this.localStorage = new LocalStorage(this);
/*Weiterleitung je nach Login Status */
......@@ -69,14 +75,14 @@ public class MainActivity extends AppCompatActivity {
/**
* Start ranging for beacons.
**/
if(RANGING){
if(RANGING && isBluetoothAvailable()){
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);
setAppList(event);
} if (list.isEmpty()){
showMessage(getResources().getString(R.string.noBeaconFound));
}
......@@ -88,8 +94,15 @@ public class MainActivity extends AppCompatActivity {
}
private void setAppList(Event event) {
List<AppContainer> container = DBHelper.getAllAps();
AppContainer app = container.get(0);
Feedback feedback = app.getFeedback();
Log.d(TAG, "TEST "+feedback.getFeedbackId());
}
private void setEvent(Event event) {
this.event = event;
this.event = this.event;
}
private void getEventFromServer(Beacon nearestBeacon) {
......@@ -101,15 +114,11 @@ public class MainActivity extends AppCompatActivity {
@Override
public void done(Event event) {
if (event != null){
setEvent(event);
event.save();
//setEvent(event);
}else{
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "aktuell findet keine Veranstaltung statt", Toast.LENGTH_SHORT).show();
}
});
showMessage(getResources().getString(R.string.noCurrentEvent));
}
}
......@@ -123,6 +132,7 @@ public class MainActivity extends AppCompatActivity {
// 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
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
......@@ -145,10 +155,18 @@ public class MainActivity extends AppCompatActivity {
}
public static boolean isBluetoothAvailable(){
final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
return (bluetoothAdapter != null && bluetoothAdapter.isEnabled());
}
private void showMessage(String message) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
private void showMessage(final String message) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}
});
}
}
......@@ -7,6 +7,7 @@ import java.util.List;
import classes.Event;
import classes.LocalStorage;
import classes.apps.AppContainer;
import co.uk.rushorm.core.RushSearch;
/**
......@@ -42,5 +43,10 @@ public class DBHelper {
}
public static List<AppContainer> getAllAps(){
List<AppContainer> container = new RushSearch().find(AppContainer.class);
return container;
}
}
......@@ -2,17 +2,18 @@
<string name="app_name">BIDL</string>
<!-- Splash Activity !-->
<string name="title_activity_splashscreen">SplashscreenActivity</string>
<string name="splashMessage">Es wird nach Beacons gesucht&#8230;</string>
<string name="imageViewDescription">University Logo</string>
<string name="gifImageViewDescription">Loadingspinner</string>
<string name="noBeaconFound">Kein Beacon in der Nähe!</string>
<string name="title_activity_login">Sign in</string>
<!-- Main Activity !-->
<string name="clickAgainToExit">Erneut klicken zum Beenden!</string>
<string name="noCurrentEvent">In diesem Raum findet aktuell keine Veranstaltung statt</string>
<string name="ESTIMOTE_PROXIMITY_UUID">B9407F30-F5F8-466E-AFF9-25556B57FE6D</string>
<!-- Login Activity !-->
<string name="title_activity_login">Sign in</string>
<string name="imageViewDescription">University Logo</string>
<string name="hintTextEmail">E-Mail Adresse</string>
<string name="hintTextPass">Passwort</string>
<string name="checkBoxDescription">Eingeloggt bleiben</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment