Commit a9c70991 authored by Christof Wolke's avatar Christof Wolke

code formatiert, beschreibungen ergänzt und letzte bugs behoben

parent 4d0d3c8f
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
android:label="@string/title_activity_search" android:label="@string/title_activity_search"
android:screenOrientation="sensorPortrait" /> android:screenOrientation="sensorPortrait" />
<activity <activity
android:name=".member_view.ProfilActivity" android:name=".member_view.ProfileActivity"
android:label="@string/title_activity_profil" android:label="@string/title_activity_profil"
android:screenOrientation="sensorPortrait" /> android:screenOrientation="sensorPortrait" />
<activity android:name=".member_view.ChangePasswordActivity" /> <activity android:name=".member_view.ChangePasswordActivity" />
......
...@@ -3,7 +3,6 @@ package classes; ...@@ -3,7 +3,6 @@ package classes;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import co.uk.rushorm.core.RushCore;
/** /**
* Created by Christof on 25.08.2016. * Created by Christof on 25.08.2016.
...@@ -85,15 +84,6 @@ public class LocalStorage { ...@@ -85,15 +84,6 @@ public class LocalStorage {
return this.userLocalDatabase.getString("image", ""); return this.userLocalDatabase.getString("image", "");
} }
/**
* Ändert den Pfad zum Profilbild des Nutzers
* @param image neuen Pfad zum Profilbild des Nutzers
*/
public void setUserImage(String image) {
SharedPreferences.Editor spEditor = this.userLocalDatabase.edit();
spEditor.putString("image", image);
spEditor.apply();
}
/** /**
......
...@@ -2,7 +2,20 @@ package de.uni_oldenburg.bidl; ...@@ -2,7 +2,20 @@ package de.uni_oldenburg.bidl;
import android.app.Application; import android.app.Application;
import java.util.ArrayList;
import java.util.List;
import classes.apps.event.Event;
import classes.apps.event.EventTime;
import classes.apps.event.Favorite;
import classes.apps.feedback.Feedback;
import classes.apps.feedback.Question;
import classes.apps.forum.Comment;
import classes.apps.forum.CommentList;
import classes.apps.forum.Forum;
import classes.apps.materials.Materials;
import co.uk.rushorm.android.AndroidInitializeConfig; import co.uk.rushorm.android.AndroidInitializeConfig;
import co.uk.rushorm.core.Rush;
import co.uk.rushorm.core.RushCore; import co.uk.rushorm.core.RushCore;
/** /**
...@@ -21,7 +34,22 @@ public class AppClass extends Application { ...@@ -21,7 +34,22 @@ public class AppClass extends Application {
* */ * */
//this.deleteDatabase("bidl.db"); //this.deleteDatabase("bidl.db");
AndroidInitializeConfig config = new AndroidInitializeConfig(getApplicationContext()); List<Class<? extends Rush>> classes = new ArrayList<>();
// Add classes
classes.add(Event.class);
classes.add(EventTime.class);
classes.add(Favorite.class);
classes.add(Feedback.class);
classes.add(Question.class);
classes.add(Comment.class);
classes.add(Forum.class);
classes.add(Materials.class);
AndroidInitializeConfig config = new AndroidInitializeConfig(this);
config.setClasses(classes);
RushCore.initialize(config); RushCore.initialize(config);
} }
} }
package de.uni_oldenburg.bidl; package de.uni_oldenburg.bidl;
import android.content.Intent; import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
...@@ -17,20 +18,20 @@ import classes.LocalStorage; ...@@ -17,20 +18,20 @@ import classes.LocalStorage;
import de.uni_oldenburg.bidl.guest_view.LoginActivity; import de.uni_oldenburg.bidl.guest_view.LoginActivity;
import de.uni_oldenburg.bidl.home_view.MainActivity; import de.uni_oldenburg.bidl.home_view.MainActivity;
import de.uni_oldenburg.bidl.member_view.FavoriteActivity; import de.uni_oldenburg.bidl.member_view.FavoriteActivity;
import de.uni_oldenburg.bidl.member_view.ProfilActivity; import de.uni_oldenburg.bidl.member_view.ProfileActivity;
import de.uni_oldenburg.bidl.member_view.SearchActivity; import de.uni_oldenburg.bidl.member_view.SearchActivity;
import services.db.DBHelper; import services.db.DBHelper;
/** /**
* Created by Christof on 30.08.2016. * BaseActivity for each Activity, which has an menu
*/ */
public class BaseActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{ public class BaseActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
protected LocalStorage localStorage; protected LocalStorage localStorage;
protected int drawerLayout; protected int drawerLayout;
@SuppressWarnings("deprecation")
protected void setMenu(int drawer_layout) { protected void setMenu(int drawer_layout) {
setDrawerLayout(drawer_layout); setDrawerLayout(drawer_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
...@@ -51,19 +52,27 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On ...@@ -51,19 +52,27 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
@Override @Override
public void onBackPressed() { public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(drawerLayout); DrawerLayout drawer = (DrawerLayout) findViewById(drawerLayout);
if (drawer != null) {
if (drawer.isDrawerOpen(GravityCompat.START)) { if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START); drawer.closeDrawer(GravityCompat.START);
} else { } else {
super.onBackPressed(); super.onBackPressed();
} }
} else {
super.onBackPressed();
}
} }
/**
* Menu
*
* @param item clicked menuItem
* @return true
*/
@SuppressWarnings("StatementWithEmptyBody") @SuppressWarnings("StatementWithEmptyBody")
@Override @Override
public boolean onNavigationItemSelected(MenuItem item) { public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// Handle navigation view item clicks here. // Handle navigation view item clicks here.
int id = item.getItemId(); int id = item.getItemId();
...@@ -75,7 +84,7 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On ...@@ -75,7 +84,7 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
toProfilActivity(); toProfilActivity();
} else if (id == R.id.nav_favorite) { } else if (id == R.id.nav_favorite) {
toFavoriteAcitvity(); toFavoriteAcitvity();
} else if (id == R.id.nav_logout){ } else if (id == R.id.nav_logout) {
toLoginActivity(); toLoginActivity();
} else if (id == R.id.nav_share) { } else if (id == R.id.nav_share) {
shareEvent(); shareEvent();
...@@ -91,7 +100,7 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On ...@@ -91,7 +100,7 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
} }
private void toProfilActivity() { private void toProfilActivity() {
startActivity(new Intent(this, ProfilActivity.class)); startActivity(new Intent(this, ProfileActivity.class));
} }
private void toSearchActivity() { private void toSearchActivity() {
...@@ -102,9 +111,9 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On ...@@ -102,9 +111,9 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
Intent sendIntent = new Intent(); Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setAction(Intent.ACTION_SEND);
Event event = DBHelper.getEvent(); Event event = DBHelper.getEvent();
if(event != null ){ if (event != null) {
if (event.getCurrentEnd() >= getCurrentTime()){ if (event.getCurrentEnd() >= getCurrentTime()) {
sendIntent.putExtra(Intent.EXTRA_TEXT, "Ich sitze gerade in der Veranstaltung "+event.getName()+"."); sendIntent.putExtra(Intent.EXTRA_TEXT, "Ich sitze gerade in der Veranstaltung " + event.getName() + ".");
} else { } else {
sendIntent.putExtra(Intent.EXTRA_TEXT, "Ich benutze gerade die Bidl App der Universität Oldenburg!"); sendIntent.putExtra(Intent.EXTRA_TEXT, "Ich benutze gerade die Bidl App der Universität Oldenburg!");
} }
...@@ -136,13 +145,15 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On ...@@ -136,13 +145,15 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
/** /**
* Get the current Time * Get the current Time
*
* @return the current Time with the format from the Server * @return the current Time with the format from the Server
*/ */
@SuppressWarnings("deprecation")
public int getCurrentTime() { public int getCurrentTime() {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
Date date = calendar.getTime(); Date date = calendar.getTime();
int hour = date.getHours()*60; int hour = date.getHours() * 60;
int minute = date.getMinutes(); int minute = date.getMinutes();
return hour+minute; return hour + minute;
} }
} }
...@@ -30,13 +30,11 @@ public class LoginActivity extends AppCompatActivity { ...@@ -30,13 +30,11 @@ public class LoginActivity extends AppCompatActivity {
private Button btLogin; private Button btLogin;
private TextView tvRegister; private TextView tvRegister;
private LocalStorage localStorage;
/** values **/ /** values **/
private String email; private String email;
private String password; private String password;
private boolean keepLoggedIn; private boolean keepLoggedIn;
private static final String TOAST_ERROR_MESSAGE = "Falsche Login Daten"; private LocalStorage localStorage;
...@@ -87,7 +85,7 @@ public class LoginActivity extends AppCompatActivity { ...@@ -87,7 +85,7 @@ public class LoginActivity extends AppCompatActivity {
LoginActivity.this.runOnUiThread(new Runnable() { LoginActivity.this.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
Toast.makeText(getApplicationContext(), TOAST_ERROR_MESSAGE, Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), getString(R.string.wrongLoginData), Toast.LENGTH_SHORT).show();
view.setEnabled(true); view.setEnabled(true);
} }
}); });
......
...@@ -15,17 +15,23 @@ import services.servercommunication.NetworkService; ...@@ -15,17 +15,23 @@ import services.servercommunication.NetworkService;
public class RegisterActivity extends AppCompatActivity { public class RegisterActivity extends AppCompatActivity {
/** GUI **/ /**
* GUI
**/
private EditText etUsername; private EditText etUsername;
private EditText etEmail; private EditText etEmail;
private EditText etPassword; private EditText etPassword;
private EditText etRepeatPassword;
private Button btNewAccount; private Button btNewAccount;
private TextView tvToLogin; private TextView tvToLogin;
/** values **/ /**
* values
**/
private String name; private String name;
private String email; private String email;
private String password; private String password;
private String repeatPassword;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -36,6 +42,7 @@ public class RegisterActivity extends AppCompatActivity { ...@@ -36,6 +42,7 @@ public class RegisterActivity extends AppCompatActivity {
etUsername = (EditText) findViewById(R.id.etFullName); etUsername = (EditText) findViewById(R.id.etFullName);
etEmail = (EditText) findViewById(R.id.etEmail); etEmail = (EditText) findViewById(R.id.etEmail);
etPassword = (EditText) findViewById(R.id.etPassword); etPassword = (EditText) findViewById(R.id.etPassword);
etRepeatPassword = (EditText) findViewById(R.id.etRepeatPassword);
btNewAccount = (Button) findViewById(R.id.btRegister); btNewAccount = (Button) findViewById(R.id.btRegister);
tvToLogin = (TextView) findViewById(R.id.link_to_login); tvToLogin = (TextView) findViewById(R.id.link_to_login);
...@@ -46,17 +53,23 @@ public class RegisterActivity extends AppCompatActivity { ...@@ -46,17 +53,23 @@ public class RegisterActivity extends AppCompatActivity {
name = etUsername.getText().toString(); name = etUsername.getText().toString();
email = etEmail.getText().toString(); email = etEmail.getText().toString();
password = etPassword.getText().toString(); password = etPassword.getText().toString();
repeatPassword = etRepeatPassword.getText().toString();
if (!(name.isEmpty() || email.isEmpty() || password.isEmpty())){ if (!(name.isEmpty() || email.isEmpty() || password.isEmpty() || repeatPassword.isEmpty())) {
if (isEmailOk()){ if (isEmailOk()) {
if (isPasswordOk()) {
btNewAccount.setEnabled(false); btNewAccount.setEnabled(false);
register(email, name, password); register(email, name, password);
toMainActivity(); toMainActivity();
}else { } else {
showToastMessage(getString(R.string.register_response_passwordDontMatch));
}
} else {
showToastMessage(getString(R.string.register_response_emailNotOk)); showToastMessage(getString(R.string.register_response_emailNotOk));
} }
}else{ } else {
showToastMessage(getString(R.string.register_response_fillOutAllFields)); showToastMessage(getString(R.string.register_response_fillOutAllFields));
} }
...@@ -71,6 +84,14 @@ public class RegisterActivity extends AppCompatActivity { ...@@ -71,6 +84,14 @@ public class RegisterActivity extends AppCompatActivity {
}); });
} }
/**
* check if Passwords are equal
*
* @return true: ok
*/
private boolean isPasswordOk() {
return password.equals(repeatPassword);
}
private void toMainActivity() { private void toMainActivity() {
...@@ -79,6 +100,7 @@ public class RegisterActivity extends AppCompatActivity { ...@@ -79,6 +100,7 @@ public class RegisterActivity extends AppCompatActivity {
/** /**
* checks, if the email is valid * checks, if the email is valid
*
* @return true: ok * @return true: ok
*/ */
private boolean isEmailOk() { private boolean isEmailOk() {
...@@ -88,6 +110,7 @@ public class RegisterActivity extends AppCompatActivity { ...@@ -88,6 +110,7 @@ public class RegisterActivity extends AppCompatActivity {
/** /**
* Register a User in the DB. * Register a User in the DB.
*
* @param email Email from the USer. * @param email Email from the USer.
* @param name Name of the new User. * @param name Name of the new User.
* @param password Password from the User. * @param password Password from the User.
...@@ -121,6 +144,7 @@ public class RegisterActivity extends AppCompatActivity { ...@@ -121,6 +144,7 @@ public class RegisterActivity extends AppCompatActivity {
/** /**
* Shows the User different messages. * Shows the User different messages.
*
* @param message Toast message for the User. * @param message Toast message for the User.
*/ */
private void showToastMessage(final String message) { private void showToastMessage(final String message) {
......
...@@ -13,14 +13,20 @@ import services.servercommunication.NetworkService; ...@@ -13,14 +13,20 @@ import services.servercommunication.NetworkService;
public class ResetPasswordActivity extends AppCompatActivity { public class ResetPasswordActivity extends AppCompatActivity {
// Tag constant for Logging /**
* Tag constant for Logging
**/
private static final String Tag = ResetPasswordActivity.class.getSimpleName(); private static final String Tag = ResetPasswordActivity.class.getSimpleName();
// GUI /**
* GUI
**/
private EditText resetPwEditText; private EditText resetPwEditText;
private Button resetPwButton; private Button resetPwButton;
// Values /**
* values
**/
private String mail; private String mail;
...@@ -35,35 +41,35 @@ public class ResetPasswordActivity extends AppCompatActivity { ...@@ -35,35 +41,35 @@ public class ResetPasswordActivity extends AppCompatActivity {
} }
public void resetPassword(View view){ public void resetPassword(View view) {
mail = resetPwEditText.getText().toString(); mail = resetPwEditText.getText().toString();
if (mail.isEmpty()){ if (mail.isEmpty()) {
Toast.makeText(getApplicationContext(), getString(R.string.resetPassword_emial), Toast.makeText(getApplicationContext(), getString(R.string.resetPassword_emial),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
} } else {
else {
NetworkService.resetPassword(mail, new NetworkService.RequestResetPasswordHandler() { NetworkService.resetPassword(mail, new NetworkService.RequestResetPasswordHandler() {
@Override @Override
public void done(final String statusResponse) { public void done(final String statusResponse) {
ResetPasswordActivity.this.runOnUiThread(new Runnable() { ResetPasswordActivity.this.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (statusResponse.equals("ok")) { switch (statusResponse) {
case "ok":
Toast.makeText(getApplicationContext(), Toast.makeText(getApplicationContext(),
getString(R.string.resetPassword_success), getString(R.string.resetPassword_success),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
break;
case "error":
} else if (statusResponse.equals("error")) {
Toast.makeText(getApplicationContext(), Toast.makeText(getApplicationContext(),
getString(R.string.resetPassword_error), getString(R.string.resetPassword_error),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
} else { break;
default:
Toast.makeText(getApplicationContext(), Toast.makeText(getApplicationContext(),
getString(R.string.register_response_noconnection), getString(R.string.register_response_noconnection),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
break;
} }
} }
...@@ -77,7 +83,7 @@ public class ResetPasswordActivity extends AppCompatActivity { ...@@ -77,7 +83,7 @@ public class ResetPasswordActivity extends AppCompatActivity {
} }
public void onBackPressed(){ public void onBackPressed() {
startActivity(new Intent(this, LoginActivity.class)); startActivity(new Intent(this, LoginActivity.class));
finish(); finish();
} }
......
package de.uni_oldenburg.bidl.listfragment; package de.uni_oldenburg.bidl.listfragment;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.support.v4.app.ListFragment; import android.support.v4.app.ListFragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
...@@ -9,10 +8,12 @@ import android.util.Log; ...@@ -9,10 +8,12 @@ import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ListView;
import classes.MyList; import classes.MyList;
import classes.apps.forum.CommentList; import classes.apps.forum.CommentList;
import de.uni_oldenburg.bidl.R; import de.uni_oldenburg.bidl.R;
import services.ViewHelper.SwipeDismissListViewTouchListener;
/** /**
* Created by Christof on 01.09.2016. * Created by Christof on 01.09.2016.
...@@ -64,8 +65,20 @@ public class SuperListFragment extends ListFragment implements SwipeRefreshLayou ...@@ -64,8 +65,20 @@ public class SuperListFragment extends ListFragment implements SwipeRefreshLayou
@Override @Override
public void onViewCreated(View view, Bundle savedInstanceState) { public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
if (withSwipe){ if (withSwipe) {
//ToDo: das Löschen von Daten durch swipen realisieren. SwipeDismissListViewTouchListener swipeListener = new SwipeDismissListViewTouchListener(this.getListView(), new SwipeDismissListViewTouchListener.DismissCallbacks() {
@Override
public boolean canDismiss(int position) {
return true;
}
@Override
public void onDismiss(ListView listView, int[] reverseSortedPositions) {
communicator.onSwipeDismiss(listView, reverseSortedPositions);
}
});
this.getListView().setOnTouchListener(swipeListener);
this.getListView().setOnScrollListener(swipeListener.makeScrollListener());
} }
swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipelayout); swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipelayout);
if (isRefreshable){ if (isRefreshable){
...@@ -108,6 +121,7 @@ public class SuperListFragment extends ListFragment implements SwipeRefreshLayou ...@@ -108,6 +121,7 @@ public class SuperListFragment extends ListFragment implements SwipeRefreshLayou
this.communicator = null; this.communicator = null;
} }
@Override @Override
public void onRefresh() { public void onRefresh() {
communicator.updateFragList(); communicator.updateFragList();
......
...@@ -2,7 +2,6 @@ package de.uni_oldenburg.bidl.member_view; ...@@ -2,7 +2,6 @@ package de.uni_oldenburg.bidl.member_view;