Commit 1447abca authored by Christof Wolke's avatar Christof Wolke
Browse files

adding menu

parent 127949bc
......@@ -47,18 +47,19 @@ dependencies {
})
// Import Estimote SDK (https://github.com/Estimote/Android-SDK)
compile 'com.estimote:sdk:0.10.8@aar'
// Import LoganSquare JSON library (https://github.com/bluelinelabs/LoganSquare)
compile 'com.bluelinelabs:logansquare:1.3.6'
// 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.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'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
compile 'com.android.support:support-v4:24.1.1'
testCompile 'junit:junit:4.12'
apt 'com.bluelinelabs:logansquare-compiler:1.3.6'
compile 'com.estimote:sdk:0.10.8@aar'
compile 'com.bluelinelabs:logansquare:1.3.6'
compile 'com.squareup.okhttp:okhttp:2.7.1'
compile 'co.uk.rushorm:rushandroid:1.1.11'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:design:24.2.0'
}
\ No newline at end of file
......@@ -43,16 +43,6 @@
android:name="Rush_log"
android:value="false" />
<activity
android:name=".home_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=".guest_view.LoginActivity"
android:screenOrientation="sensorPortrait" />
......@@ -71,11 +61,19 @@
</activity>
<activity
android:name=".member_view.ForumActivity"
android:screenOrientation="sensorPortrait"/>
android:screenOrientation="sensorPortrait" />
<activity
android:name=".member_view.FeedbackActivity"
android:screenOrientation="sensorPortrait"/>
android:screenOrientation="sensorPortrait" />
<activity
android:name=".home_view.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
......@@ -3,6 +3,8 @@ package classes;
import android.content.Context;
import android.content.SharedPreferences;
import co.uk.rushorm.core.RushCore;
/**
* Created by Christof on 25.08.2016.
*/
......@@ -122,4 +124,6 @@ public class LocalStorage {
spEditor.putString("email", userEmail);
spEditor.apply();
}
}
package de.uni_oldenburg.bidl.home_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.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
......@@ -26,10 +32,11 @@ import classes.Event;
import classes.LocalStorage;
import de.uni_oldenburg.bidl.R;
import de.uni_oldenburg.bidl.guest_view.LoginActivity;
import services.db.DBHelper;
import services.servercommunication.NetworkService;
public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
/** Tag for Logging **/
private static final String TAG = MainActivity.class.getSimpleName();
......@@ -54,17 +61,17 @@ public class MainActivity extends AppCompatActivity {
private Beacon nearestBeacon;
private ArrayList<String> apps = new ArrayList<>();
private ArrayAdapter<String> adapter;
private Event event;
protected LocalStorage localStorage;
private ProgressDialog progress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setMenu();
/** init **/
adapter = new ArrayAdapter<>(MainActivity.this, R.layout.grid_item, R.id.grid_text, apps);
grid = (GridView) findViewById(R.id.mainActivityGrid);
......@@ -132,12 +139,14 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
noBeaconTV.setVisibility(View.INVISIBLE);
grid.setVisibility(View.VISIBLE);
if (!list.isEmpty() && !list.get(0).equals(nearestBeacon)){
nearestBeacon = list.get(0);
getEventFromServer(nearestBeacon);
} if (list.isEmpty()){
progress.dismiss();
grid.setVisibility(View.INVISIBLE);
noBeaconTV.setText(R.string.noBeaconFound);
noBeaconTV.setVisibility(View.VISIBLE);
}
......@@ -161,12 +170,13 @@ public class MainActivity extends AppCompatActivity {
public void run() {
setTitle(event.getName());
updateData(event.getApps());
setEvent(event);
}
});
}else{
progress.dismiss();
showMessage(getResources().getString(R.string.noCurrentEvent));
progress.dismiss();
showMessage(getResources().getString(R.string.noCurrentEvent));
}
}
......@@ -228,4 +238,82 @@ public class MainActivity extends AppCompatActivity {
}
});
}
private void setMenu() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_search) {
//ToDo: toSearcheActivity
} else if (id == R.id.nav_home) {
toHomeActivity();
} else if (id == R.id.nav_profil) {
//TODO: toProfilActivity
} else if (id == R.id.nav_favorite) {
//TODO: toFavoriteActivity
} else if (id == R.id.nav_logout){
toLoginActivity();
} else if (id == R.id.nav_share) {
shareEvent();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
protected void shareEvent() {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Ich sitze gerade in der Veranstaltung "+event.getName()+".");
sendIntent.setType("text/plain");
startActivity(sendIntent);
}
protected void toLoginActivity() {
//löscht den Activity-History-Stack und öffnet LoginActivity
startActivity(new Intent(this, LoginActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
localStorage.deleteUserData();
//löscht gespeicherte Events
DBHelper.clearAll();
finish();
}
protected void toHomeActivity() {
startActivity(new Intent(this, MainActivity.class));
}
public void setEvent(Event event) {
this.event = event;
}
}
......@@ -8,6 +8,7 @@ import java.util.List;
import classes.Event;
import classes.LocalStorage;
import classes.apps.AppContainer;
import co.uk.rushorm.core.RushCore;
import co.uk.rushorm.core.RushSearch;
/**
......@@ -43,5 +44,17 @@ public class DBHelper {
}
/**
* Löscht Recommendations, Locations, Favoriten und Check-Ins von der Datenbank
*/
public static void clearAll() {
clearEvents();
}
private static void clearEvents() {
RushCore.getInstance().deleteAll(Event.class);
}
}
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