Commit 058d5b3d authored by Christof Wolke's avatar Christof Wolke

Favoriten und SearchActivity

parent df564b49
......@@ -46,18 +46,23 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
// Import Estimote SDK (https://github.com/Estimote/Android-SDK)
// Import LoganSquare JSON library (https://github.com/bluelinelabs/LoganSquare)
// Import OkHttp library (https://github.com/square/okhttp)
// Import RushOrm library (https://github.com/Stuart-campbell/RushOrm)
// Import GifImageView library (https://github.com/felipecsl/GifImageView)
testCompile 'junit:junit:4.12'
apt 'com.bluelinelabs:logansquare-compiler:1.3.6'
// 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'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
// Import Glide Image library (https://github.com/bumptech/glide)
compile 'com.github.bumptech.glide:glide:3.6.1'
// Import Glide OkHttp module
compile 'com.github.bumptech.glide:okhttp-integration:1.3.1@aar'
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'
......
......@@ -24,7 +24,7 @@
android:value="de.uni_oldenburg.bidl.classes" />
<meta-data
android:name="Rush_db_version"
android:value="4" />
android:value="6" />
<meta-data
android:name="Rush_db_name"
android:value="bidl.db" />
......@@ -65,6 +65,9 @@
<activity
android:name=".member_view.FeedbackActivity"
android:screenOrientation="sensorPortrait" />
<activity
android:name=".member_view.MaterialsActivity"
android:screenOrientation="sensorPortrait" />
<activity
android:name=".home_view.MainActivity"
android:label="@string/app_name"
......@@ -75,8 +78,20 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".member_view.MaterialsActivity" />
<activity android:name=".member_view.SearchActivity"></activity>
<activity
android:name=".member_view.SearchActivity"
android:label="@string/title_activity_search"
android:screenOrientation="sensorPortrait" />
<activity
android:name=".member_view.ProfilActivity"
android:label="@string/title_activity_profil"
android:screenOrientation="sensorPortrait" />
<activity android:name=".member_view.ChangePasswordActivity" />
<activity android:name=".guest_view.ResetPasswordActivity" />
<activity
android:name=".member_view.FavoriteActivity"
android:label="@string/title_activity_favorite"
android:theme="@style/AppTheme"></activity>
</application>
</manifest>
\ No newline at end of file
package classes.apps.event;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import java.io.Serializable;
import co.uk.rushorm.core.RushObject;
/**
* Created by Christof on 15.09.2016.
*/
@JsonObject
public class EventTime extends RushObject implements Serializable {
@JsonField(name = "id")
int eventTimeId;
@JsonField(name = "dayOfWeek")
String dayOfWeek;
@JsonField(name = "start")
String start;
@JsonField(name = "end")
String end;
public EventTime() {
}
public EventTime(int eventTimeId, String dayOfWeek, String start, String end) {
this.eventTimeId = eventTimeId;
this.dayOfWeek = dayOfWeek;
this.start = start;
this.end = end;
}
public int getEventTimeId() {
return eventTimeId;
}
public void setEventTimeId(int eventTimeId) {
this.eventTimeId = eventTimeId;
}
public String getDayOfWeek() {
return dayOfWeek;
}
public void setDayOfWeek(String dayOfWeek) {
this.dayOfWeek = dayOfWeek;
}
public String getStart() {
return start;
}
public void setStart(String start) {
this.start = start;
}
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
@Override
public String toString() {
return "EventTime{" +
"eventTimeId=" + eventTimeId +
", dayOfWeek='" + dayOfWeek + '\'' +
", start='" + start + '\'' +
", end='" + end + '\'' +
'}';
}
}
package classes.apps.event;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import java.io.Serializable;
import java.util.List;
import co.uk.rushorm.core.RushObject;
import co.uk.rushorm.core.annotations.RushList;
/**
* Created by Christof on 15.09.2016.
*/
@JsonObject
public class Favorite extends RushObject implements Serializable {
@JsonField(name = "id")
private int favoriteId;
@JsonField(name = "name")
private String name;
@JsonField(name = "eventTimes")
@RushList(classType = EventTime.class)
private List<EventTime> eventTimeList;
public Favorite() {
}
public Favorite(int favoriteId, String name, List<EventTime> eventTimeList) {
this.favoriteId = favoriteId;
this.name = name;
this.eventTimeList = eventTimeList;
}
public int getFavoriteId() {
return favoriteId;
}
public void setFavoriteId(int favoriteId) {
this.favoriteId = favoriteId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<EventTime> getEventTimeList() {
return eventTimeList;
}
public void setEventTimeList(List<EventTime> eventTimeList) {
this.eventTimeList = eventTimeList;
}
@Override
public String toString() {
return "Favorite{" +
"favoriteId=" + favoriteId +
", name='" + name + '\'' +
", eventTimeList=" + eventTimeList +
'}';
}
}
......@@ -9,10 +9,12 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import classes.Event;
import classes.apps.event.Event;
import classes.LocalStorage;
import de.uni_oldenburg.bidl.guest_view.LoginActivity;
import de.uni_oldenburg.bidl.home_view.MainActivity;
import de.uni_oldenburg.bidl.member_view.FavoriteActivity;
import de.uni_oldenburg.bidl.member_view.ProfilActivity;
import de.uni_oldenburg.bidl.member_view.SearchActivity;
import services.db.DBHelper;
......@@ -22,14 +24,16 @@ import services.db.DBHelper;
public class BaseActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
protected LocalStorage localStorage;
protected int drawerLayout;
protected void setMenu() {
protected void setMenu(int drawer_layout) {
setDrawerLayout(drawer_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
DrawerLayout drawer = (DrawerLayout) findViewById(drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
......@@ -37,11 +41,13 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
this.localStorage = new LocalStorage(this);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
DrawerLayout drawer = (DrawerLayout) findViewById(drawerLayout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
......@@ -63,20 +69,28 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
} else if (id == R.id.nav_home) {
toHomeActivity();
} else if (id == R.id.nav_profil) {
//TODO: toProfilActivity
toProfilActivity();
} else if (id == R.id.nav_favorite) {
//TODO: toFavoriteActivity
toFavoriteAcitvity();
} else if (id == R.id.nav_logout){
toLoginActivity();
} else if (id == R.id.nav_share) {
shareEvent();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
DrawerLayout drawer = (DrawerLayout) findViewById(drawerLayout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
private void toFavoriteAcitvity() {
startActivity(new Intent(this, FavoriteActivity.class));
}
private void toProfilActivity() {
startActivity(new Intent(this, ProfilActivity.class));
}
private void toSearchActivity() {
startActivity(new Intent(this, SearchActivity.class));
}
......@@ -85,7 +99,12 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
Event event = DBHelper.getEvent();
sendIntent.putExtra(Intent.EXTRA_TEXT, "Ich sitze gerade in der Veranstaltung "+event.getName()+".");
if(event !=null){
sendIntent.putExtra(Intent.EXTRA_TEXT, "Ich sitze gerade in der Veranstaltung "+event.getName()+".");
} else {
sendIntent.putExtra(Intent.EXTRA_TEXT, "Ich benutze gerade die Bidl App der Universität Oldenburg!");
}
sendIntent.setType("text/plain");
startActivity(sendIntent);
}
......@@ -103,4 +122,8 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
protected void toHomeActivity() {
startActivity(new Intent(this, MainActivity.class));
}
public void setDrawerLayout(int drawerLayout) {
this.drawerLayout = drawerLayout;
}
}
......@@ -128,7 +128,7 @@ public class LoginActivity extends AppCompatActivity {
}
private void toForgotPasswortActivity() {
// TODO: 04.08.2016 Create to ForgotPasswortActivity
startActivity(new Intent(getApplicationContext(), ResetPasswordActivity.class));
}
private void toMainActivity() {
......
package de.uni_oldenburg.bidl.guest_view;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import de.uni_oldenburg.bidl.R;
import services.servercommunication.NetworkService;
public class ResetPasswordActivity extends AppCompatActivity {
// Tag constant for Logging
private static final String Tag = ResetPasswordActivity.class.getSimpleName();
// GUI
private EditText resetPwEditText;
private Button resetPwButton;
// Values
private String mail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reset_password);
//init
resetPwEditText = (EditText) findViewById(R.id.resetPWEditText);
resetPwButton = (Button) findViewById(R.id.resetPWButton);
}
public void resetPassword(View view){
mail = resetPwEditText.getText().toString();
if (mail.isEmpty()){
Toast.makeText(getApplicationContext(), getString(R.string.resetPassword_emial),
Toast.LENGTH_SHORT).show();
}
else {
NetworkService.resetPassword(mail, new NetworkService.RequestResetPasswordHandler() {
@Override
public void done(final String statusResponse) {
ResetPasswordActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (statusResponse.equals("ok")) {
Toast.makeText(getApplicationContext(),
getString(R.string.resetPassword_success),
Toast.LENGTH_SHORT).show();
} else if (statusResponse.equals("error")) {
Toast.makeText(getApplicationContext(),
getString(R.string.resetPassword_error),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(),
getString(R.string.register_response_noconnection),
Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
}
public void onBackPressed(){
startActivity(new Intent(this, LoginActivity.class));
finish();
}
}
......@@ -4,14 +4,12 @@ import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
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;
import com.estimote.sdk.Beacon;
import com.estimote.sdk.BeaconManager;
......@@ -27,12 +25,11 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import classes.Event;
import classes.apps.event.Event;
import classes.LocalStorage;
import de.uni_oldenburg.bidl.BaseActivity;
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 BaseActivity {
......@@ -73,7 +70,7 @@ public class MainActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setMenu();
setMenu(R.id.drawer_layout_main);
/** init **/
adapter = new ArrayAdapter<>(MainActivity.this, R.layout.grid_item, R.id.grid_text, apps);
grid = (GridView) findViewById(R.id.mainActivityGrid);
......@@ -87,13 +84,15 @@ public class MainActivity extends BaseActivity {
if(!localStorage.isLoggedIn()){
startActivity(new Intent(this, LoginActivity.class));
this.finish();
} else {
setProgressDialog();
}
/** 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();
if (getIntent().getExtras() != null){
setRanging(false);
......@@ -104,7 +103,6 @@ public class MainActivity extends BaseActivity {
/**
* Start ranging for beacons.
**/
Log.d(TAG, RANGING.toString());
if(RANGING && isBluetoothAvailable()){
startRanging();
}
......
package de.uni_oldenburg.bidl.listfragment;
import android.content.Context;
import android.icu.util.TimeUnit;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.text.DateFormatSymbols;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import classes.apps.event.EventTime;
import de.uni_oldenburg.bidl.R;
/**
* Created by Christof on 15.09.2016.
*/
public class EventTimeAdapter extends BaseAdapter {
private Context context;
private List<EventTime> eventTimeList;
private TextView dayTV;
private TextView startTV;
private TextView endTV;
private String[] weekday=new String[7];
public EventTimeAdapter(Context context, List<EventTime> eventTimeList){
this.context = context;
this.eventTimeList = eventTimeList;
}
@Override
public int getCount() {
return eventTimeList.size();
}
@Override
public Object getItem(int i) {
return eventTimeList.get(i);
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int postion, View view, ViewGroup parent) {
EventTime eventTime = this.eventTimeList.get(postion);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View item = inflater.inflate(R.layout.popup_item, parent, false);
this.dayTV = (TextView) item.findViewById(R.id.popupDay);
this.startTV = (TextView) item.findViewById(R.id.popupdStart);
this.endTV = (TextView) item.findViewById(R.id.popupEnd);
String start = getTime(eventTime.getStart());
String end = getTime(eventTime.getEnd());
String day = getDay(eventTime.getDayOfWeek());
this.dayTV.setText(day);
this.startTV.setText(start+" -");
this.endTV.setText(end);
return item;
}
private String getTime(String time) {
long hours = java.util.concurrent.TimeUnit.MINUTES.toHours(Integer.parseInt(time));
long minute = Integer.parseInt(time) - java.util.concurrent.TimeUnit.HOURS.toMinutes(hours);
return String.format("%02d", hours) + ":" + String.format("%02d",minute);
}
private String getDay(String day) {
DateFormatSymbols symbols = DateFormatSymbols.getInstance();
weekday = symbols.getShortWeekdays();
return weekday[Integer.parseInt(day)];
}
}
package de.uni_oldenburg.bidl.member_view;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import classes.LocalStorage;
import classes.User;
import de.uni_oldenburg.bidl.R;
import services.servercommunication.NetworkService;
public class ChangePasswordActivity extends AppCompatActivity {
private static final String TAG = ChangePasswordActivity.class.getSimpleName();
// Values
private User user;
private String newPassword;
private String currentPassword;
private String repeatPassword;
private Boolean equalPassword;
// GUI
private EditText newPasswordEditText;
private EditText currentPasswordEditText;
private EditText repeatPasswordEditText;
private Button changePasswordButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_password);
LocalStorage storage = new LocalStorage(this);
this.user = storage.getLoggedInUser();
newPasswordEditText = (EditText) findViewById(R.id.newPasswordEditText);
currentPasswordEditText = (EditText) findViewById(R.id.currentPasswordEditText);
repeatPasswordEditText = (EditText) findViewById(R.id.repeatNewPasswordEditText);
changePasswordButton = (Button) findViewById(R.id.changePasswordButton);
}
public void changePassword(View view) {
// hole aktuelles Passwort
currentPassword = currentPasswordEditText.getText().toString();
// hole neues Passwort
newPassword = newPasswordEditText.getText().toString();
// hole das neue Passwort, wiederholt
repeatPassword = repeatPasswordEditText.getText().toString();
// vergleiche Passwörter
equalPassword = newPassword.equals(repeatPassword);
if(currentPassword.isEmpty() || newPassword.isEmpty() || repeatPassword.isEmpty()) {
toastMessage(getString(R.string.enterPassword));
}
else if (equalPassword){
NetworkService.changePassword((int) user.getUserId(), currentPassword, newPassword, new NetworkService.RequestChangePasswordHandler() {
@Override
public void done(String response) {
if (response.equals("ok")) {
toastMessage(getString(R.string.profil_passwordChangeSuccess));
} else if (response.equals("error")) {
toastMessage(getString(R.string.profil_passwordChangeFail));
} else {
toastMessage(getString(R.string.register_response_noconnection));
}
}
});
} else {
toastMessage(getString(R.string.register_response_passwordDontMatch));
}
}
/**
* Zeigt eine Toastmessage an
* @param message Nachricht, die angezeigt werden soll
*/
protected void toastMessage(final String message) {
this.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(ChangePasswordActivity.this, message, Toast.LENGTH_SHORT).show();
}
});
}
}