From 6fb5577ac8cda269b9f624a68f63001a2b798c1c Mon Sep 17 00:00:00 2001 From: rishabh92 Date: Sat, 18 Jun 2016 01:44:53 -0500 Subject: [PATCH 1/4] registration fixed --- .gitignore | 1 + DonorOnCall_Client.iml | 19 ++++++++ .../com/donor/oncall/DonorApi/DonorApi.java | 6 +-- .../oncall/DonorApi/ServiceGenerator.java | 2 +- .../donor/oncall/fragments/LoginFragment.java | 15 +++--- .../fragments/RegisterationFragment.java | 46 +++++++++++-------- .../main/res/layout/registeration_screen.xml | 6 ++- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 9 files changed, 67 insertions(+), 34 deletions(-) create mode 100644 DonorOnCall_Client.iml diff --git a/.gitignore b/.gitignore index 185d1bf..f3f8faf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.iml .gradle /local.properties /.idea/workspace.xml diff --git a/DonorOnCall_Client.iml b/DonorOnCall_Client.iml new file mode 100644 index 0000000..22fe60d --- /dev/null +++ b/DonorOnCall_Client.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/donor/oncall/DonorApi/DonorApi.java b/app/src/main/java/com/donor/oncall/DonorApi/DonorApi.java index 59d1be7..2fd0a09 100644 --- a/app/src/main/java/com/donor/oncall/DonorApi/DonorApi.java +++ b/app/src/main/java/com/donor/oncall/DonorApi/DonorApi.java @@ -15,15 +15,15 @@ */ public interface DonorApi { @Headers("Content-Type: application/json") - @POST("/doc/gateWay") + @POST("/login") void login(@Body JSONObject jsonVal, Callback callback); @Headers("Content-Type: application/json") - @POST("/doc/register") + @POST("/register") void register(@Body JsonObject jsonVal, Callback callback); @Headers("Content-Type: application/json") - @POST("/doc/donor") + @POST("/donor") void requestDonor(@Body JsonObject jsonVal, Callback callback); } diff --git a/app/src/main/java/com/donor/oncall/DonorApi/ServiceGenerator.java b/app/src/main/java/com/donor/oncall/DonorApi/ServiceGenerator.java index 78db68d..f284801 100644 --- a/app/src/main/java/com/donor/oncall/DonorApi/ServiceGenerator.java +++ b/app/src/main/java/com/donor/oncall/DonorApi/ServiceGenerator.java @@ -10,7 +10,7 @@ */ public class ServiceGenerator { - public static final String API_BASE_URL = "http://ec2-52-74-63-14.ap-southeast-1.compute.amazonaws.com"; + public static final String API_BASE_URL = "http://45.55.137.90:8000/"; private static RestAdapter.Builder builder = new RestAdapter.Builder() .setEndpoint(API_BASE_URL) diff --git a/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java b/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java index e0b37f4..819ffee 100644 --- a/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java +++ b/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java @@ -69,11 +69,11 @@ public boolean validateEmailId(String email){ if (email == null || email.isEmpty()){ usernameField.setError("User name cannot be empty"); }else { - if (email.matches(emailPattern)){ + // if (email.matches(emailPattern)){ status = true; - }else { - usernameField.setError("Not a valid email Address"); - } + //}else { + // usernameField.setError("Not a valid email Address"); + // } } return status; } @@ -101,12 +101,12 @@ public void setUpLogin(){ rootView.findViewById(R.id.signin).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - JSONObject jsonObject = new JSONObject(); + final JSONObject jsonObject = new JSONObject(); if (validateEmailIdAndPassword()) { try { jsonObject.put("userName", username); - jsonObject.put("passWord", password); + jsonObject.put("password", password); donorApi.login(jsonObject, new Callback() { @@ -122,7 +122,8 @@ public void success(Response response, Response response2) { @Override public void failure(RetrofitError error) { - Log.d(TAG, "Success " + error.getMessage()); + Log.d("tag", jsonObject.toString()); + Log.d(TAG, "Error " + error.toString()); } }); diff --git a/app/src/main/java/com/donor/oncall/fragments/RegisterationFragment.java b/app/src/main/java/com/donor/oncall/fragments/RegisterationFragment.java index 00b3cb0..e4e1b56 100644 --- a/app/src/main/java/com/donor/oncall/fragments/RegisterationFragment.java +++ b/app/src/main/java/com/donor/oncall/fragments/RegisterationFragment.java @@ -141,7 +141,7 @@ public boolean checkPwd(){ if (isNullOrEmpty(password)){ if (isNullOrEmpty(cfrmpassword)){ if (!password.equals(cfrmpassword)){ - cfrmpwdField.setError("Passwords donot match"); + cfrmpwdField.setError("Passwords do not match"); status = false; } }else { @@ -188,13 +188,14 @@ public boolean checkDonorRecipient(){ boolean status = true; if (donor.isChecked()){ type = "Donor"; + } + else if (recipient.isChecked()){ + type = "Recipient"; }else { status =false; donor.setError("Select either donor or recipient"); } - if (recipient.isChecked()){ - type = "Recipient"; - } + return status; } @@ -235,30 +236,39 @@ public void onClick(View v) { if (validateFields()){ try { progressDialog.show(); - jsonObject.addProperty("userName", username); - jsonObject.addProperty("passWord", password); jsonObject.addProperty("name", name); - jsonObject.addProperty("bloodGroup", bloodGrp); - jsonObject.addProperty("type", type); jsonObject.addProperty("dob", dob); + jsonObject.addProperty("bloodGroup", bloodGrp); + jsonObject.addProperty("password", password); + jsonObject.addProperty("phoneNo","9456866253"); + jsonObject.addProperty("email",email); + jsonObject.addProperty("userName", username); + + + + // jsonObject.addProperty("type", type); + Log.d(TAG,jsonObject.toString()); donorApi.register(jsonObject,new Callback< Response >() { @Override public void success(Response response, Response response2) { Log.d(TAG, "Success " + response.getReason()); - String json = new String(((TypedByteArray) response.getBody()).getBytes()); - replaceViewFragment(new LoginFragment(),false); - JsonParser parser = new JsonParser(); - JsonElement responseJson = parser.parse(json); + // String json = new String(((TypedByteArray) response.getBody()).getBytes()); + // JsonParser parser = new JsonParser(); + // JsonElement responseJson = parser.parse(json); progressDialog.setMessage("Thank you for Signin up"); - signUpResponse(responseJson.getAsJsonObject()); - Log.d(TAG, "Success " + json); + progressDialog.dismiss(); + replaceViewFragment(new LoginFragment(),false); + // signUpResponse(responseJson.getAsJsonObject()); + // Log.d(TAG, "Success " + json); } @Override public void failure(RetrofitError error) { - Log.d(TAG, "Success " + error.getMessage()); + Log.d(TAG, "Error " + error.getMessage()); + progressDialog.setMessage("An error occured"); } + }); }catch (Exception e){ @@ -267,13 +277,13 @@ public void failure(RetrofitError error) { } }); } - - public void signUpResponse(JsonObject jsonObject){ + /* public void signUpResponse(JsonObject jsonObject){ if (jsonObject.get("registration").getAsString().equals("success")) { progressDialog.hide(); replaceViewFragment(new LoginFragment(),true); } - } + }*/ + } diff --git a/app/src/main/res/layout/registeration_screen.xml b/app/src/main/res/layout/registeration_screen.xml index 19cb5cd..6a1a3ea 100644 --- a/app/src/main/res/layout/registeration_screen.xml +++ b/app/src/main/res/layout/registeration_screen.xml @@ -102,7 +102,8 @@ android:id="@+id/pwd" android:layout_width="match_parent" android:layout_height="wrap_content" - android:hint="password" /> + android:hint="password" + android:password="true"/> + android:hint="confirm password" + android:password="true"/> Date: Sat, 18 Jun 2016 01:47:34 -0500 Subject: [PATCH 2/4] remove .iml file --- DonorOnCall_Client.iml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 DonorOnCall_Client.iml diff --git a/DonorOnCall_Client.iml b/DonorOnCall_Client.iml deleted file mode 100644 index 22fe60d..0000000 --- a/DonorOnCall_Client.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file From c912fbacdc358261fe2584c038d5fdd7cac833fd Mon Sep 17 00:00:00 2001 From: rishabh92 Date: Sat, 18 Jun 2016 01:51:48 -0500 Subject: [PATCH 3/4] uncommenting validation --- .../java/com/donor/oncall/fragments/LoginFragment.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java b/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java index 819ffee..5b63a22 100644 --- a/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java +++ b/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java @@ -69,11 +69,11 @@ public boolean validateEmailId(String email){ if (email == null || email.isEmpty()){ usernameField.setError("User name cannot be empty"); }else { - // if (email.matches(emailPattern)){ + if (email.matches(emailPattern)){ status = true; - //}else { - // usernameField.setError("Not a valid email Address"); - // } + }else { + usernameField.setError("Not a valid email Address"); + } } return status; } From b7e32986a1776ecf8d2a2f807d337ed1439a03c2 Mon Sep 17 00:00:00 2001 From: Rishabh Singh Date: Sat, 18 Jun 2016 01:54:07 -0500 Subject: [PATCH 4/4] validation uncomment --- .../java/com/donor/oncall/fragments/LoginFragment.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java b/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java index 819ffee..5b63a22 100644 --- a/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java +++ b/app/src/main/java/com/donor/oncall/fragments/LoginFragment.java @@ -69,11 +69,11 @@ public boolean validateEmailId(String email){ if (email == null || email.isEmpty()){ usernameField.setError("User name cannot be empty"); }else { - // if (email.matches(emailPattern)){ + if (email.matches(emailPattern)){ status = true; - //}else { - // usernameField.setError("Not a valid email Address"); - // } + }else { + usernameField.setError("Not a valid email Address"); + } } return status; }