diff --git a/.idea/libraries/android_android_23.xml b/.idea/libraries/android_android_23.xml
deleted file mode 100644
index a279d4a..0000000
--- a/.idea/libraries/android_android_23.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/animated_vector_drawable_23_3_0.xml b/.idea/libraries/animated_vector_drawable_23_3_0.xml
new file mode 100644
index 0000000..c887d48
--- /dev/null
+++ b/.idea/libraries/animated_vector_drawable_23_3_0.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/appcompat_v7_23_3_0.xml b/.idea/libraries/appcompat_v7_23_3_0.xml
new file mode 100644
index 0000000..39b4f84
--- /dev/null
+++ b/.idea/libraries/appcompat_v7_23_3_0.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/design_23_3_0.xml b/.idea/libraries/design_23_3_0.xml
new file mode 100644
index 0000000..6172f7d
--- /dev/null
+++ b/.idea/libraries/design_23_3_0.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/recyclerview_v7_23_3_0.xml b/.idea/libraries/recyclerview_v7_23_3_0.xml
new file mode 100644
index 0000000..7b42040
--- /dev/null
+++ b/.idea/libraries/recyclerview_v7_23_3_0.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/support_annotations_23_4_0.xml b/.idea/libraries/support_annotations_23_4_0.xml
deleted file mode 100644
index 87c058c..0000000
--- a/.idea/libraries/support_annotations_23_4_0.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/support_v4_23_3_0.xml b/.idea/libraries/support_v4_23_3_0.xml
new file mode 100644
index 0000000..68eb591
--- /dev/null
+++ b/.idea/libraries/support_v4_23_3_0.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/support_vector_drawable_23_3_0.xml b/.idea/libraries/support_vector_drawable_23_3_0.xml
new file mode 100644
index 0000000..55e107d
--- /dev/null
+++ b/.idea/libraries/support_vector_drawable_23_3_0.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/volley_1_0_0.xml b/.idea/libraries/volley_1_0_0.xml
index 81a83dd..8e317b7 100644
--- a/.idea/libraries/volley_1_0_0.xml
+++ b/.idea/libraries/volley_1_0_0.xml
@@ -1,8 +1,8 @@
-
+
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b736f67..e678e27 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,11 +2,10 @@
-
-
-
+
+
@@ -28,10 +27,9 @@
-
+
-
-
+
\ No newline at end of file
diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/LoginActivity.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/LoginActivity.java
index 8b71b22..2056df6 100644
--- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/LoginActivity.java
+++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/LoginActivity.java
@@ -74,6 +74,9 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
private EditText mPasswordView;
private View mProgressView;
private View mLoginFormView;
+ private TextView mRegisterButton;
+ private Button mLoginButton;
+
private final String TAG = "Login Activity";
@@ -85,13 +88,19 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- //Remove title bar
- this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_login);
this.self = this;
this.layout = (LinearLayout) findViewById(R.id.layout);
mUsernameView = (EditText) findViewById(R.id.al_username);
mPasswordView = (EditText) findViewById(R.id.al_password);
+ mLoginFormView = findViewById(R.id.login_form);
+ mProgressView = findViewById(R.id.login_progress);
+ showProgress(false);
+
+ // Remove Auto Focus from the Text Fields
+ layout.setFocusable(true);
+ layout.setFocusableInTouchMode(true);
+
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
@@ -102,30 +111,29 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
return false;
}
});
-// Button mRegisterButton = (Button) findViewById(R.id.al_register_button);
-// mRegisterButton.setOnClickListener(new OnClickListener() {
-// @Override
-// public void onClick(View view) {
-// Log.d(TAG, "Register....... this section under construction");
-// //attemptRegister(); // TODO : implement
-// }
-// });
- Button mEmailSignInButton = (Button) findViewById(R.id.al_login_button);
- mEmailSignInButton.setOnClickListener(new OnClickListener() {
+ mRegisterButton = (TextView) findViewById(R.id.al_register_button);
+ mRegisterButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Log.d(TAG, "going to Register...page");
+ Intent registerActivity = new Intent(LoginActivity.this, RegisterActivity.class);
+ startActivity(registerActivity);
+ }
+ });
+
+ mLoginButton = (Button) findViewById(R.id.al_login_button);
+ mLoginButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "Login.......");
+ showProgress(false);
attemptLogin();
}
});
mLoginFormView = findViewById(R.id.login_form);
mProgressView = findViewById(R.id.login_progress);
-
- // Remove Auto Focus from the Text Fields
- layout.setFocusable(true);
- layout.setFocusableInTouchMode(true);
}
private void populateAutoComplete() {
@@ -201,6 +209,8 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
String username = mUsernameView.getText().toString();
String password = mPasswordView.getText().toString();
+ boolean cancel = false;
+ View focusView = null;
// http request register
JSONObject tempJson = new JSONObject();
@@ -223,7 +233,6 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
@Override
public void onResponse(JSONObject response) {
try {
- // if(response.get("user") != null) {
if(!response.isNull("user")) {
Log.e(TAG, "onLoginSuccess => user exist"); // TODO: REMOVE console
Intent personalSpaceActivity = new Intent(LoginActivity.this, PersonalSpaceActivity.class);
diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/RegisterActivity.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/RegisterActivity.java
new file mode 100644
index 0000000..337cd92
--- /dev/null
+++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/RegisterActivity.java
@@ -0,0 +1,172 @@
+package com.android_app.matan.ara.sagi.thesocialnotework;
+
+import android.content.Intent;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.android.volley.Response;
+import com.android.volley.VolleyError;
+
+import org.json.JSONObject;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class RegisterActivity extends AppCompatActivity {
+
+ private EditText mUsernameView;
+ private EditText mPasswordView;
+ private EditText mEmailView;
+ private Button registerButton;
+ private Button testBtn;
+ private RegisterActivity self;
+
+ protected RelativeLayout layout;
+ private final String TAG = "Register Activity";
+
+ private final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
+ private final String REG_PATH = "/register";
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_register);
+
+ mUsernameView = (EditText) findViewById(R.id.ra_username);
+ mPasswordView = (EditText) findViewById(R.id.ra_password);
+ mEmailView = (EditText) findViewById(R.id.ra_email);
+
+ this.self = this;
+ this.layout = (RelativeLayout) findViewById(R.id.ra_layout);
+
+ // Remove Auto Focus from the Text Fields
+ layout.setFocusable(true);
+ layout.setFocusableInTouchMode(true);
+
+ Log.d(TAG, "oncreate...");
+ testBtn = (Button) findViewById(R.id.test_button);
+ testBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Log.d(TAG, "NOW??.......");
+
+ }
+ });
+
+ registerButton = (Button) findViewById(R.id.ra_register_button);
+ registerButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Log.d(TAG, "here.......");
+ attemptRegister();
+ }
+ });
+
+ }
+
+ private boolean isUsernameValid(String username) {
+ return username.length() > 0;
+ }
+ private boolean isPasswordValid(String password) {
+ return password.length() > 3;
+ }
+ private boolean isEmailValid(String email) {
+ boolean isValid = false;
+
+ String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
+ CharSequence inputStr = email;
+
+ Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(inputStr);
+ if (matcher.matches()) {
+ isValid = true;
+ }
+ Log.d(TAG, "isValid: " + isValid);
+ return isValid;
+ }
+
+ private boolean isParamsValid(String username, String password, String email) {
+ Log.d(TAG, "user: " + username);
+ Log.d(TAG, "pwd: " + password);
+ Log.d(TAG, "email: " + email);
+
+ if(TextUtils.isEmpty(username) || !isUsernameValid(username) || TextUtils.isEmpty(password) || !isPasswordValid(password)) {
+ return false;
+ } else if(TextUtils.isEmpty(email) || !isEmailValid(email)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private void attemptRegister() {
+// showProgress(true);
+ Log.d(TAG, "in attemptRegister: Registering..");
+ if (isParamsValid(mUsernameView.getText().toString(), mPasswordView.getText().toString(), mEmailView.getText().toString())) {
+
+ Log.d(TAG, "params are valid");
+
+ String username = mUsernameView.getText().toString();
+ String password = mPasswordView.getText().toString();
+ String email = mEmailView.getText().toString();
+
+ boolean cancel = false;
+ View focusView = null;
+
+ // http request register
+ JSONObject tempJson = new JSONObject();
+ try {
+ tempJson.put("username", username);
+ tempJson.put("password", password);
+ tempJson.put("email", email);
+ } catch (Exception e) {
+ Log.d(TAG, e.toString());
+ }
+
+ VolleyUtilSingleton.getInstance(RegisterActivity.this).post(BASE_URL + REG_PATH, tempJson, onRegisterSuccess, onRegisterError);
+ } else {
+// showProgress(false);
+ Log.d(TAG, "Invalid params - make sure username exist, password is 4 characters or more & email is valid");
+ }
+ }
+
+ Response.Listener onRegisterSuccess = new Response.Listener() {
+ @Override
+ public void onResponse(JSONObject response) {
+ try {
+ if(!response.isNull("user")) {
+ Log.e(TAG, "onLoginSuccess => user exist"); // TODO: REMOVE console
+ Intent loginActivity = new Intent(RegisterActivity.this, LoginActivity.class);
+// Bundle loginUserBundle = new Bundle();
+// loginUserBundle.putString("user_id", response.getJSONObject("user").getString("id"));
+// personalSpaceActivity.putExtras(loginUserBundle);
+ startActivity(loginActivity);
+ } else {
+// showProgress(false);
+ Log.d(TAG, "Cannot create user, " + response.get("user"));
+ }
+ }catch (Exception e) {
+ Log.e(TAG, "onRegisterSuccess:" + e.getMessage());
+ }
+ }
+ };
+
+ Response.ErrorListener onRegisterError = new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+// showProgress(false);
+ Toast.makeText(self , "Username, Password or Email are Incorrect", Toast.LENGTH_LONG).show();
+ Log.d(TAG, "onRegisterError: msg: " + error.getMessage());
+ }
+ };
+}
diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml
index 03073f0..fdfe2f8 100644
--- a/app/src/main/res/layout/activity_login.xml
+++ b/app/src/main/res/layout/activity_login.xml
@@ -43,7 +43,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
- android:hint="Usename" />
+ android:hint="Username" />
@@ -69,11 +69,11 @@
android:padding="12dp"
android:text="Login"/>
-
diff --git a/app/src/main/res/layout/activity_register.xml b/app/src/main/res/layout/activity_register.xml
new file mode 100644
index 0000000..df8e6ae
--- /dev/null
+++ b/app/src/main/res/layout/activity_register.xml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 8313d48..a78f07e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -3,10 +3,10 @@
Email
- Username
- Password
Login
Register
+ Register
+ No account yet? Create one for FREE
Sign in
This email address is invalid
This password is too short
@@ -23,6 +23,7 @@
Content
Throw Me
Note Me
- Map
+ Username
+ Password