Commit 127949bc authored by Christof Wolke's avatar Christof Wolke
Browse files

Display all apps from currentEvent

parent 1d96eec0
...@@ -2,16 +2,13 @@ ...@@ -2,16 +2,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.uni_oldenburg.bidl"> package="de.uni_oldenburg.bidl">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application <application
android:name="de.uni_oldenburg.bidl.AppClass" android:name=".AppClass"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
...@@ -21,7 +18,7 @@ ...@@ -21,7 +18,7 @@
<!-- <!--
Don't increase version on every single DB model change, use Rush_debug instead (see below). 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 de.uni_oldenburg.bidl.AppClass also contains code to allow dropping the database
--> -->
<meta-data <meta-data
android:name="Rush_classes_package" android:name="Rush_classes_package"
android:value="de.uni_oldenburg.bidl.classes" /> android:value="de.uni_oldenburg.bidl.classes" />
...@@ -47,21 +44,37 @@ ...@@ -47,21 +44,37 @@
android:value="false" /> android:value="false" />
<activity <activity
android:name="de.uni_oldenburg.bidl.base_view.MainActivity" android:name=".home_view.MainActivity"
android:label="Bidl" android:label= "@string/app_name"
android:screenOrientation="sensorPortrait"> android:screenOrientation="sensorPortrait">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="de.uni_oldenburg.bidl.guest_view.LoginActivity" <activity
android:screenOrientation="sensorPortrait"/> android:name=".guest_view.LoginActivity"
android:screenOrientation="sensorPortrait" />
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
</intent-filter> </intent-filter>
<activity android:name="de.uni_oldenburg.bidl.guest_view.RegisterActivity"
<activity
android:name=".guest_view.RegisterActivity"
android:parentActivityName=".guest_view.LoginActivity" 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"/> android:screenOrientation="sensorPortrait"/>
</application> </application>
......
...@@ -16,7 +16,7 @@ import com.estimote.sdk.SystemRequirementsChecker; ...@@ -16,7 +16,7 @@ import com.estimote.sdk.SystemRequirementsChecker;
import classes.LocalStorage; import classes.LocalStorage;
import classes.User; import classes.User;
import de.uni_oldenburg.bidl.R; import de.uni_oldenburg.bidl.R;
import de.uni_oldenburg.bidl.base_view.MainActivity; import de.uni_oldenburg.bidl.home_view.MainActivity;
import services.servercommunication.NetworkService; import services.servercommunication.NetworkService;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
......
...@@ -10,7 +10,7 @@ import android.widget.TextView; ...@@ -10,7 +10,7 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import de.uni_oldenburg.bidl.R; import de.uni_oldenburg.bidl.R;
import de.uni_oldenburg.bidl.base_view.MainActivity; import de.uni_oldenburg.bidl.home_view.MainActivity;
import services.servercommunication.NetworkService; import services.servercommunication.NetworkService;
public class RegisterActivity extends AppCompatActivity { public class RegisterActivity extends AppCompatActivity {
......
package de.uni_oldenburg.bidl.base_view; package de.uni_oldenburg.bidl.home_view;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; 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.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -14,6 +18,7 @@ import com.estimote.sdk.BeaconManager; ...@@ -14,6 +18,7 @@ import com.estimote.sdk.BeaconManager;
import com.estimote.sdk.Region; import com.estimote.sdk.Region;
import com.estimote.sdk.SystemRequirementsChecker; import com.estimote.sdk.SystemRequirementsChecker;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -32,19 +37,27 @@ public class MainActivity extends AppCompatActivity { ...@@ -32,19 +37,27 @@ public class MainActivity extends AppCompatActivity {
/** Soll nach Beacons gesucht werden? **/ /** Soll nach Beacons gesucht werden? **/
private static final Boolean RANGING = true; 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 **/ /** Estimote Beacon UUID **/
private static UUID PROXIMITY_UUID; private static UUID PROXIMITY_UUID;
/** GUI **/ /** GUI **/
private TextView beaconID; private GridView grid;
private TextView noBeaconTV;
/** values **/ /** values **/
private Region region; private Region region;
private BeaconManager beaconManager; private BeaconManager beaconManager;
private Beacon nearestBeacon; private Beacon nearestBeacon;
private Event event; private ArrayList<String> apps = new ArrayList<>();
private ArrayAdapter<String> adapter;
protected LocalStorage localStorage; protected LocalStorage localStorage;
private ProgressDialog progress;
...@@ -53,7 +66,11 @@ public class MainActivity extends AppCompatActivity { ...@@ -53,7 +66,11 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
/** init **/ /** 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)); PROXIMITY_UUID = UUID.fromString(getResources().getString(R.string.ESTIMOTE_PROXIMITY_UUID));
this.localStorage = new LocalStorage(this); this.localStorage = new LocalStorage(this);
...@@ -66,26 +83,68 @@ public class MainActivity extends AppCompatActivity { ...@@ -66,26 +83,68 @@ public class MainActivity extends AppCompatActivity {
/** region is the hole university --> all beacons have the same proximity_UUID **/ /** region is the hole university --> all beacons have the same proximity_UUID **/
region = new Region("ranged region", PROXIMITY_UUID, null, null); region = new Region("ranged region", PROXIMITY_UUID, null, null);
beaconManager = new BeaconManager(this); beaconManager = new BeaconManager(this);
beaconManager.setForegroundScanPeriod(4000, 1000);
setProgressDialog();
/** /**
* Start ranging for beacons. * 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()){ if(RANGING && isBluetoothAvailable()){
beaconManager.setRangingListener(new BeaconManager.RangingListener() { beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override @Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) { public void onBeaconsDiscovered(Region region, List<Beacon> list) {
noBeaconTV.setVisibility(View.INVISIBLE);
if (!list.isEmpty() && !list.get(0).equals(nearestBeacon)){ if (!list.isEmpty() && !list.get(0).equals(nearestBeacon)){
nearestBeacon = list.get(0); nearestBeacon = list.get(0);
getEventFromServer(nearestBeacon); getEventFromServer(nearestBeacon);
} if (list.isEmpty()){ } 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) { private void getEventFromServer(Beacon nearestBeacon) {
...@@ -95,13 +154,18 @@ public class MainActivity extends AppCompatActivity { ...@@ -95,13 +154,18 @@ public class MainActivity extends AppCompatActivity {
NetworkService.getEvent(uud, major, minor, new NetworkService.RequestGetEventHandler() { NetworkService.getEvent(uud, major, minor, new NetworkService.RequestGetEventHandler() {
@Override @Override
public void done(Event event) { public void done(final Event event) {
if (event != null){ if (event != null){
//TODO: event.getApps und die Liste dem gridadapter übergeben und die Main View verändern. MainActivity.this.runOnUiThread(new Runnable() {
Log.d(TAG, "TEST: "+event.getEventId()+" "+event.getName()+" "+event.getApps()); @Override
public void run() {
setTitle(event.getName());
updateData(event.getApps());
}
});
}else{ }else{
progress.dismiss();
showMessage(getResources().getString(R.string.noCurrentEvent)); showMessage(getResources().getString(R.string.noCurrentEvent));
} }
...@@ -110,11 +174,22 @@ public class MainActivity extends AppCompatActivity { ...@@ -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 @Override
protected void onResume(){ protected void onResume(){
super.onResume(); super.onResume();
// is Bluetooth on, is Location on, etc. // is Bluetooth on, is Location on, etc.
//TODO: only check if Bluethooth is on.
SystemRequirementsChecker.checkWithDefaultDialogs(this); SystemRequirementsChecker.checkWithDefaultDialogs(this);
// Start ranging for beacons, when the activity appears on the screen // Start ranging for beacons, when the activity appears on the screen
......
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"));
}
}
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"));
}
}
<?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>
<?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>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <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" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main" android:id="@+id/activity_main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="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 <TextView
android:id="@+id/BeaconID" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:layout_height="wrap_content" android:id="@+id/noBeaconTV"
android:text="Hello World!" android:gravity="center"
app:layout_constraintBottom_toBottomOf="@+id/activity_main" android:visibility="invisible"/>
app:layout_constraintLeft_toLeftOf="@+id/activity_main"
app:layout_constraintRight_toRightOf="@+id/activity_main" <GridView
app:layout_constraintTop_toTopOf="@+id/activity_main" /> 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> </android.support.constraint.ConstraintLayout>
<?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
<resources> <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> <string name="noBeaconFound">Kein Beacon in der Nähe!</string>
...@@ -34,5 +34,4 @@ ...@@ -34,5 +34,4 @@
<string name="register_response_noconnection">Es konnte keine Verbindung zum Server hergestellt werden!</string> <string name="register_response_noconnection">Es konnte keine Verbindung zum Server hergestellt werden!</string>
</resources> </resources>
...@@ -5,7 +5,7 @@ buildscript { ...@@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { 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 // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
} }
......
Supports Markdown
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