Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-Android into developer

Updated Ticket.class
  • Loading branch information
Marshalluous committed May 28, 2017
2 parents 7608c01 + af7d96b commit 462458e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 20 deletions.
2 changes: 0 additions & 2 deletions app/src/main/java/ch/hsr/afterhour/gui/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,10 @@ private void attemptLogin() {
}

private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@");
}

private boolean isPasswordValid(String password) {
//TODO: Replace this with your own logic
return password.length() > 3;
}

Expand Down
15 changes: 6 additions & 9 deletions app/src/main/java/ch/hsr/afterhour/gui/RegisterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,15 @@ private void attemptRegister() {
String birthYear = mBirthYear.getText().toString();
String birthMonth = mBirthMonth.getText().toString();
String birthDay = mBirthDay.getText().toString();
buf.append(birthYear)
buf.append(birthDay)
.append("-")
.append(birthMonth)
.append("-")
.append(birthDay);
.append(birthYear);
String birthday = buf.toString();



boolean cancel = false;
View focusView = null;
boolean cancel = false;
View focusView = null;

// Check for a valid password, if the user entered one.
if (TextUtils.isEmpty(firstName)) {
Expand Down Expand Up @@ -179,7 +177,7 @@ else if (!passwordRepeat.equals(password)) {
} else {
try {
user = new User(lastName, firstName, email, Gender.MALE,
vorwahl + mobile, birthday, false);
vorwahl + mobile, birthday, false, null, password);
showProgress(true);
mAuthTask = new RegisterUserTask();
mAuthTask.execute();
Expand Down Expand Up @@ -218,12 +216,10 @@ public void onAnimationEnd(Animator animation) {
}

private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@");
}

private boolean isPasswordValid(String password) {
//TODO: Replace this with your own logic
return password.length() > 3;
}

Expand Down Expand Up @@ -255,6 +251,7 @@ protected void onPostExecute(final Boolean success) {

if (success) {
Intent intent = new Intent(getBaseContext(), MainActivity.class);
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
} else {
Snackbar snackbar = Snackbar.make(
Expand Down
22 changes: 19 additions & 3 deletions app/src/main/java/ch/hsr/afterhour/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public class User implements Serializable {
private static final int BARCODE_SIZE = 250;
private static final String PREFIX_USER_BC = "USR-ZRH-";

private final BarcodeGenerator barcodeGenerator = new QrBarcodeGenerator();
private final DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
private final transient BarcodeGenerator barcodeGenerator = new QrBarcodeGenerator();
private final transient DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");

private int id;
private Integer id;
private String lastName;
private String firstName;
private String email;
private String password;
private String mobileNumber;
private Date dateOfBirth;
private Gender gender;
Expand Down Expand Up @@ -62,6 +63,21 @@ public User(String lastName, String firstName,
this.profileImage = profileImage;
}

public User(String lastName, String firstName,
String email, Gender gender, String mobileNumber,
String dateOfBirth, boolean isEmployee, Bitmap profileImage, String password) throws ParseException {

this.lastName = lastName;
this.firstName = firstName;
this.email = email;
this.gender = gender;
this.mobileNumber = mobileNumber;
this.dateOfBirth = dateFormat.parse(dateOfBirth);
this.employee = isEmployee;
this.profileImage = profileImage;
this.password = password;
}

public User(String lastName, String firstName,
String email, Gender gender, String mobileNumber,
String dateOfBirth, boolean isEmployee) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ch.hsr.afterhour.service.server;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.io.Serializable;

import ch.viascom.groundwork.foxhttp.parser.FoxHttpParser;

/**
* Created by eluch on 26.05.2017.
*/

public class CustomGsonParser implements FoxHttpParser {

private final Gson gson;

public CustomGsonParser(final Gson gson) {
this.gson = gson;
}

@Override
public Serializable serializedToObject(String json, Class<Serializable> type) {
return gson.fromJson(json, type);
}

@Override
public String objectToSerialized(Serializable o) {
return gson.toJson(o);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.net.MalformedURLException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -36,10 +40,13 @@ public class FoxHttpAPI {

public FoxHttpAPI() throws FoxHttpException {

final Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();

// Non-encrypted Client / Requests
FoxHttpClientBuilder builder = new FoxHttpClientBuilder();
builder.setFoxHttpResponseParser(new GsonParser())
.setFoxHttpRequestParser(new GsonParser())
builder.setFoxHttpResponseParser(new CustomGsonParser(gson))
.setFoxHttpRequestParser(new CustomGsonParser(gson))
.registerFoxHttpInterceptor(FoxHttpInterceptorType.RESPONSE, new DefaultServiceResultFaultInterceptor())
.addFoxHttpPlaceholderEntry("host", SERVER_PATH)
.setFoxHttpLogger(new SystemOutFoxHttpLogger(true, LOGGER_NAME))
Expand Down Expand Up @@ -73,11 +80,7 @@ public User authenticateUser(String qrCode) throws FoxHttpException, MalformedUR
}

public User login(String email, String password) throws FoxHttpException, MalformedURLException {
//Todo: Delete Temporary Login and Return requests.login
return requests.login(email, password);
// User user = new User("Muster", "Max", "me@world.com", "+41791234567", "2017-02-02", true);
// user.setId("1");
// return user;
}

public Event[] downloadEvents() throws FoxHttpException , MalformedURLException {
Expand Down

0 comments on commit 462458e

Please sign in to comment.