Merge branch 'master' of https://github.com/sagidayan/TheSocialNotework-Android
# Conflicts: # .idea/libraries/animated_vector_drawable_23_3_0.xml # .idea/libraries/appcompat_v7_23_3_0.xml # .idea/libraries/design_23_3_0.xml # .idea/libraries/recyclerview_v7_23_3_0.xml # .idea/libraries/support_annotations_23_4_0.xml # .idea/libraries/support_v4_23_3_0.xml # .idea/libraries/support_vector_drawable_23_3_0.xml # app/src/main/AndroidManifest.xml # app/src/main/res/values/strings.xml
This commit is contained in:
commit
15fce6daa2
15 changed files with 384 additions and 50 deletions
|
@ -1,9 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="android-android-23">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/platforms/android-23/android.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
14
.idea/libraries/animated_vector_drawable_23_3_0.xml
Normal file
14
.idea/libraries/animated_vector_drawable_23_3_0.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="animated-vector-drawable-23.3.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/res" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/jars/classes.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/animated-vector-drawable/23.3.0/animated-vector-drawable-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/animated-vector-drawable/23.3.0/animated-vector-drawable-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/animated-vector-drawable/23.3.0/animated-vector-drawable-23.3.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
17
.idea/libraries/appcompat_v7_23_3_0.xml
Normal file
17
.idea/libraries/appcompat_v7_23_3_0.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="appcompat-v7-23.3.0">
|
||||||
|
<ANNOTATIONS>
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/annotations.zip!/" />
|
||||||
|
</ANNOTATIONS>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/res" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/jars/classes.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
17
.idea/libraries/design_23_3_0.xml
Normal file
17
.idea/libraries/design_23_3_0.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="design-23.3.0">
|
||||||
|
<ANNOTATIONS>
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.3.0/annotations.zip!/" />
|
||||||
|
</ANNOTATIONS>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.3.0/res" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.3.0/jars/classes.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/design/23.3.0/design-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/design/23.3.0/design-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/design/23.3.0/design-23.3.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
17
.idea/libraries/recyclerview_v7_23_3_0.xml
Normal file
17
.idea/libraries/recyclerview_v7_23_3_0.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="recyclerview-v7-23.3.0">
|
||||||
|
<ANNOTATIONS>
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.3.0/annotations.zip!/" />
|
||||||
|
</ANNOTATIONS>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.3.0/jars/classes.jar!/" />
|
||||||
|
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.3.0/res" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7/23.3.0/recyclerview-v7-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7/23.3.0/recyclerview-v7-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/recyclerview-v7/23.3.0/recyclerview-v7-23.3.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
|
@ -1,11 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="support-annotations-23.4.0">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.4.0/support-annotations-23.4.0.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.4.0/support-annotations-23.4.0-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
18
.idea/libraries/support_v4_23_3_0.xml
Normal file
18
.idea/libraries/support_v4_23_3_0.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="support-v4-23.3.0">
|
||||||
|
<ANNOTATIONS>
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.3.0/annotations.zip!/" />
|
||||||
|
</ANNOTATIONS>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.3.0/res" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.3.0/jars/classes.jar!/" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.3.0/jars/libs/internal_impl-23.3.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.3.0/support-v4-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.3.0/support-v4-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/support-v4/23.3.0/support-v4-23.3.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
14
.idea/libraries/support_vector_drawable_23_3_0.xml
Normal file
14
.idea/libraries/support_vector_drawable_23_3_0.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="support-vector-drawable-23.3.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.3.0/res" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.3.0/jars/classes.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$USER_HOME$/Library/Android/sdk/extras/android/m2repository/com/android/support/support-vector-drawable/23.3.0/support-vector-drawable-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-vector-drawable/23.3.0/support-vector-drawable-23.3.0-sources.jar!/" />
|
||||||
|
<root url="jar:///opt/android-sdk/extras/android/m2repository/com/android/support/support-vector-drawable/23.3.0/support-vector-drawable-23.3.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
|
@ -1,8 +1,8 @@
|
||||||
<component name="libraryTable">
|
<component name="libraryTable">
|
||||||
<library name="volley-1.0.0">
|
<library name="volley-1.0.0">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.volley/volley/1.0.0/jars/classes.jar!/" />
|
|
||||||
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.volley/volley/1.0.0/res" />
|
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.volley/volley/1.0.0/res" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.volley/volley/1.0.0/jars/classes.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.android_app.matan.ara.sagi.thesocialnotework">
|
package="com.android_app.matan.ara.sagi.thesocialnotework">
|
||||||
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
|
@ -28,10 +27,9 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".LoginActivity"></activity>
|
<activity android:name=".LoginActivity" />
|
||||||
<activity android:name=".PersonalSpaceActivity" />
|
<activity android:name=".PersonalSpaceActivity" />
|
||||||
<activity android:name=".MapsActivity"></activity>
|
<activity android:name=".RegisterActivity"></activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -74,6 +74,9 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
|
||||||
private EditText mPasswordView;
|
private EditText mPasswordView;
|
||||||
private View mProgressView;
|
private View mProgressView;
|
||||||
private View mLoginFormView;
|
private View mLoginFormView;
|
||||||
|
private TextView mRegisterButton;
|
||||||
|
private Button mLoginButton;
|
||||||
|
|
||||||
|
|
||||||
private final String TAG = "Login Activity";
|
private final String TAG = "Login Activity";
|
||||||
|
|
||||||
|
@ -85,13 +88,19 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
//Remove title bar
|
|
||||||
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
this.self = this;
|
this.self = this;
|
||||||
this.layout = (LinearLayout) findViewById(R.id.layout);
|
this.layout = (LinearLayout) findViewById(R.id.layout);
|
||||||
mUsernameView = (EditText) findViewById(R.id.al_username);
|
mUsernameView = (EditText) findViewById(R.id.al_username);
|
||||||
mPasswordView = (EditText) findViewById(R.id.al_password);
|
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() {
|
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
|
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
|
||||||
|
@ -102,30 +111,29 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
|
||||||
return false;
|
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);
|
mRegisterButton = (TextView) findViewById(R.id.al_register_button);
|
||||||
mEmailSignInButton.setOnClickListener(new OnClickListener() {
|
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
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Log.d(TAG, "Login.......");
|
Log.d(TAG, "Login.......");
|
||||||
|
showProgress(false);
|
||||||
attemptLogin();
|
attemptLogin();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mLoginFormView = findViewById(R.id.login_form);
|
mLoginFormView = findViewById(R.id.login_form);
|
||||||
mProgressView = findViewById(R.id.login_progress);
|
mProgressView = findViewById(R.id.login_progress);
|
||||||
|
|
||||||
// Remove Auto Focus from the Text Fields
|
|
||||||
layout.setFocusable(true);
|
|
||||||
layout.setFocusableInTouchMode(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateAutoComplete() {
|
private void populateAutoComplete() {
|
||||||
|
@ -201,6 +209,8 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
|
||||||
String username = mUsernameView.getText().toString();
|
String username = mUsernameView.getText().toString();
|
||||||
String password = mPasswordView.getText().toString();
|
String password = mPasswordView.getText().toString();
|
||||||
|
|
||||||
|
boolean cancel = false;
|
||||||
|
View focusView = null;
|
||||||
|
|
||||||
// http request register
|
// http request register
|
||||||
JSONObject tempJson = new JSONObject();
|
JSONObject tempJson = new JSONObject();
|
||||||
|
@ -223,7 +233,6 @@ public class LoginActivity extends AppCompatActivity{ // implements LoaderCallba
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(JSONObject response) {
|
public void onResponse(JSONObject response) {
|
||||||
try {
|
try {
|
||||||
// if(response.get("user") != null) {
|
|
||||||
if(!response.isNull("user")) {
|
if(!response.isNull("user")) {
|
||||||
Log.e(TAG, "onLoginSuccess => user exist"); // TODO: REMOVE console
|
Log.e(TAG, "onLoginSuccess => user exist"); // TODO: REMOVE console
|
||||||
Intent personalSpaceActivity = new Intent(LoginActivity.this, PersonalSpaceActivity.class);
|
Intent personalSpaceActivity = new Intent(LoginActivity.this, PersonalSpaceActivity.class);
|
||||||
|
|
|
@ -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<JSONObject> onRegisterSuccess = new Response.Listener<JSONObject>() {
|
||||||
|
@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());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -43,7 +43,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="textEmailAddress"
|
android:inputType="textEmailAddress"
|
||||||
android:hint="Usename" />
|
android:hint="Username" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<!-- Password Label -->
|
<!-- Password Label -->
|
||||||
|
@ -69,11 +69,11 @@
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:text="Login"/>
|
android:text="Login"/>
|
||||||
|
|
||||||
<TextView android:id="@+id/link_signup"
|
<TextView android:id="@+id/al_register_button"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="24dp"
|
android:layout_marginBottom="24dp"
|
||||||
android:text="No account yet? Create one for FREE"
|
android:text="@string/create_new_account"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="16dip"/>
|
android:textSize="16dip"/>
|
||||||
|
|
||||||
|
|
77
app/src/main/res/layout/activity_register.xml
Normal file
77
app/src/main/res/layout/activity_register.xml
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context="com.android_app.matan.ara.sagi.thesocialnotework.RegisterActivity"
|
||||||
|
android:id="@+id/ra_layout">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:src="@drawable/logo"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="72dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:contentDescription="@string/logo"
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="24dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/ra_username"
|
||||||
|
android:layout_below="@+id/imageView"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:hint="Username"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:ems="10"
|
||||||
|
android:id="@+id/ra_password"
|
||||||
|
android:layout_below="@+id/ra_username"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:hint="Password"
|
||||||
|
android:enabled="true"
|
||||||
|
android:password="false"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textEmailAddress"
|
||||||
|
android:ems="10"
|
||||||
|
android:id="@+id/ra_email"
|
||||||
|
android:layout_below="@+id/ra_password"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:hint="Email"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/register"
|
||||||
|
android:id="@+id/ra_register_button"
|
||||||
|
android:layout_marginTop="56dp"
|
||||||
|
android:layout_below="@+id/ra_email"
|
||||||
|
android:layout_alignParentStart="true" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="New Button"
|
||||||
|
android:id="@+id/test_button"
|
||||||
|
android:layout_below="@+id/ra_register_button"
|
||||||
|
android:layout_alignParentStart="true" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
<!-- Strings related to login -->
|
<!-- Strings related to login -->
|
||||||
<string name="prompt_email">Email</string>
|
<string name="prompt_email">Email</string>
|
||||||
<string name="prompt_username">Username</string>
|
|
||||||
<string name="prompt_password">Password</string>
|
|
||||||
<string name="action_login">Login</string>
|
<string name="action_login">Login</string>
|
||||||
<string name="action_register">Register</string>
|
<string name="action_register">Register</string>
|
||||||
|
<string name="register">Register</string>
|
||||||
|
<string name="create_new_account">No account yet? Create one for FREE</string>
|
||||||
<string name="action_sign_in_short">Sign in</string>
|
<string name="action_sign_in_short">Sign in</string>
|
||||||
<string name="error_invalid_email">This email address is invalid</string>
|
<string name="error_invalid_email">This email address is invalid</string>
|
||||||
<string name="error_invalid_password">This password is too short</string>
|
<string name="error_invalid_password">This password is too short</string>
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
<string name="nvf_content">Content</string>
|
<string name="nvf_content">Content</string>
|
||||||
<string name="throw_me">Throw Me</string>
|
<string name="throw_me">Throw Me</string>
|
||||||
<string name="note_me">Note Me</string>
|
<string name="note_me">Note Me</string>
|
||||||
<string name="title_activity_maps">Map</string>
|
<string name="username">Username</string>
|
||||||
|
<string name="password">Password</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue