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

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);
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="de.uni_oldenburg.bidl.home_view.MainActivity">
<TextView
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:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.DrawerLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="de.uni_oldenburg.bidl.home_view.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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: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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="de.uni_oldenburg.bidl.home_view.MainActivity"
tools:showIn="@layout/app_bar_main">
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
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.home_view.MainActivity">
<TextView
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"/>
</android.support.constraint.ConstraintLayout>
</RelativeLayout>
......@@ -12,6 +12,8 @@
android:gravity="center"
android:textSize="20sp"
android:layout_margin="10dp"
android:padding="20dp"/>
android:padding="20dp"
android:elevation="2dp"
android:singleLine="false"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@color/blue"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:src="@drawable/unilogoblue" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_search"
android:icon="@drawable/ic_search_black_24dp"
android:title="@string/menuSearchTitle" />
<item
android:id="@+id/nav_home"
android:icon="@drawable/ic_home_black_24dp"
android:title="@string/menuHomeTitle"/>
<item
android:id="@+id/nav_profil"
android:icon="@drawable/ic_perm_identity_black_24dp"
android:title="@string/menuProfilTitle" />
<item
android:id="@+id/nav_favorite"
android:icon="@drawable/ic_favorite_black_24dp"
android:title="@string/menuFavoriteTitle" />
<item
android:id="@+id/nav_logout"
android:icon="@drawable/ic_exit_to_app_black_24dp"
android:title="@string/menuLogoutTitle" />
</group>
<item android:title="Social Media">
<menu>
<item
android:id="@+id/nav_share"
android:icon="@drawable/ic_menu_share"
android:title="@string/menuShareTitle" />
</menu>
</item>
</menu>
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
......@@ -5,6 +5,7 @@
<color name="colorAccent">#FF4081</color>
<color name="white">#FFFFFF</color>
<color name="grey">#c8c8ce</color>
<color name="blue">#00529E</color>
<color name="black_overlay">#66000000</color>
</resources>
......@@ -2,4 +2,8 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="nav_header_vertical_spacing">16dp</dimen>
<dimen name="nav_header_height">160dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<item name="ic_menu_camera" type="drawable">@android:drawable/ic_menu_camera</item>
<item name="ic_menu_gallery" type="drawable">@android:drawable/ic_menu_gallery</item>
<item name="ic_menu_slideshow" type="drawable">@android:drawable/ic_menu_slideshow</item>
<item name="ic_menu_manage" type="drawable">@android:drawable/ic_menu_manage</item>
<item name="ic_menu_share" type="drawable">@android:drawable/ic_menu_share</item>
<item name="ic_menu_send" type="drawable">@android:drawable/ic_menu_send</item>
</resources>
......@@ -2,7 +2,6 @@
<string name="app_name">Bidl</string>
<string name="noBeaconFound">Kein Beacon in der Nähe!</string>
......@@ -11,6 +10,15 @@
<string name="noCurrentEvent">In diesem Raum findet aktuell keine Veranstaltung statt</string>
<string name="ESTIMOTE_PROXIMITY_UUID">B9407F30-F5F8-466E-AFF9-25556B57FE6D</string>
<!-- Menu -->
<string name="menuSearchTitle">Suche</string>
<string name="menuHomeTitle">Home</string>
<string name="menuProfilTitle">Profil</string>
<string name="menuFavoriteTitle">Favoriten</string>
<string name="menuLogoutTitle">Ausloggen</string>
<string name="menuShareTitle">Teilen</string>
<!-- Login Activity !-->
<string name="title_activity_login">Sign in</string>
<string name="imageViewDescription">University Logo</string>
......@@ -32,6 +40,12 @@
<string name="register_response_registerFail">Email bereits verwendet!</string>
<string name="register_response_registerSuccess">Registrierung erfolgreich!</string>
<string name="register_response_noconnection">Es konnte keine Verbindung zum Server hergestellt werden!</string>
<string name="title_activity_main">MainActivity</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="action_settings">Settings</string>
</resources>
......@@ -20,4 +20,13 @@
<item name="android:background">@color/black_overlay</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
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