Commit c4c7f785 authored by Tanmim Hanifa's avatar Tanmim Hanifa

user page now working

parent 1d7db911
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -14,7 +14,7 @@ import java.util.Map;
public class LoginRequest extends StringRequest{
private static final String LOGIN_REQUEST_URL = "http://doc.gold.ac.uk/~thani001/travelpals/Login.php";
private static final String LOGIN_REQUEST_URL = "http://doc.gold.ac.uk/~thani001/travelpals/LoginTDB.php";
private Map<String, String> params;
public LoginRequest(String username, String password, Response.Listener<String> listener){
......
......@@ -5,6 +5,7 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import com.android.volley.Response;
......@@ -25,10 +26,21 @@ public class MainMenuActivity extends AppCompatActivity {
final ImageButton ibUserImageButton = (ImageButton) findViewById(R.id.ibUserImageButton);
Intent intent = getIntent();
final String username = intent.getStringExtra("username");
final String name = intent.getStringExtra("name");
final int age = intent.getIntExtra("age", -1);
ibUserImageButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent userIntent = new Intent(MainMenuActivity.this, UserAreaActivity.class);
userIntent.putExtra("name", name);
userIntent.putExtra("username", username);
userIntent.putExtra("age", age);
MainMenuActivity.this.startActivity(userIntent);
}
});
......
......@@ -14,7 +14,7 @@ public class RegisterRequest extends StringRequest {
private static final String REGISTER_REQUEST_URL = "http://doc.gold.ac.uk/~thani001/travelpals/Register.php";
private Map<String, String> params;
public RegisterRequest(String name, String username, int age, String password, Response.Listener<String> listener){
public RegisterRequest(String name,String username, int age, String password, Response.Listener<String> listener){
super(Method.POST, REGISTER_REQUEST_URL, listener, null);
params = new HashMap<>();
params.put("name", name);
......
......@@ -17,10 +17,10 @@ public class UserAreaActivity extends AppCompatActivity {
final EditText etName = (EditText) findViewById(R.id.etName);
Intent intent = getIntent();
String name = intent.getStringExtra("name");
int age = intent.getIntExtra("age", -1);
String username = intent.getStringExtra("username");
Intent userIntent = getIntent();
String name = userIntent.getStringExtra("name");
int age = userIntent.getIntExtra("age", -1);
String username = userIntent.getStringExtra("username");
etUsername.setText(username);
etName.setText(name);
......
......@@ -51,20 +51,17 @@ public class loginActivity extends AppCompatActivity {
boolean success = jsonResponse.getBoolean("success");
if(success){
//String name = jsonResponse.getString("name");
//int age = jsonResponse.getInt("age");
//String username = jsonResponse.getString("username");
String name = jsonResponse.getString("name");
int age = jsonResponse.getInt("age");
String username = jsonResponse.getString("username");
//Intent intent = new Intent(loginActivity.this, UserAreaActivity.class);
//intent.putExtra("name", name);
//intent.putExtra("age", age);
//intent.putExtra("username", username);
Intent intent = new Intent(loginActivity.this, MainMenuActivity.class);
intent.putExtra("name", name);
intent.putExtra("age", age);
intent.putExtra("username", username);
Intent intent1 = new Intent(loginActivity.this, MainMenuActivity.class);
//loginActivity.this.startActivity(intent);
loginActivity.this.startActivity(intent1); //Start main menu activity
loginActivity.this.startActivity(intent);
}else{
AlertDialog.Builder builder = new AlertDialog.Builder(loginActivity.this);
builder.setMessage("Login failed")
......
......@@ -17,9 +17,11 @@
android:ems="10"
android:id="@+id/etName"
android:hint="Full name"
android:layout_marginTop="76dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp"
android:layout_marginBottom="10dp"/>
<EditText
android:layout_width="wrap_content"
......@@ -28,9 +30,20 @@
android:ems="10"
android:id="@+id/etAge"
android:hint="Age"
android:layout_below="@+id/etName"
android:layout_alignStart="@+id/etUsername"
android:layout_marginTop="10dp" />
android:layout_marginBottom="10dp"
android:layout_below="@id/etName"
android:layout_alignStart="@id/etName" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etUsername"
android:hint="Username"
android:layout_below="@id/etAge"
android:layout_alignStart="@+id/etAge"
android:layout_marginBottom="10dp" />
<EditText
android:layout_width="wrap_content"
......@@ -39,28 +52,25 @@
android:ems="10"
android:id="@+id/etPassword"
android:hint="Password"
android:layout_marginBottom="10dp"
android:layout_below="@+id/etUsername"
android:layout_alignStart="@+id/etUsername"
android:layout_marginTop="17dp" />
android:layout_alignStart="@+id/etUsername" />
<Button
android:text="REGISTER"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnRegister"
android:layout_below="@+id/etPassword"
android:layout_marginTop="33dp"
android:layout_alignStart="@+id/etPassword"
android:layout_alignEnd="@+id/etPassword" />
android:layout_marginBottom="7dp"
android:layout_below="@id/etPassword"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etUsername"
android:hint="Username"
android:layout_marginTop="16dp"
android:layout_below="@+id/etAge"
android:layout_alignStart="@+id/etName" />
</RelativeLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment