passing username
This commit is contained in:
parent
451e9326b5
commit
44dd18e0e7
|
@ -0,0 +1,28 @@
|
||||||
|
package com.example.alzapp;
|
||||||
|
|
||||||
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class JumbleSender extends StringRequest {
|
||||||
|
|
||||||
|
private static final String REQUEST_URL = "https://eclectic-sweeps.000webhostapp.com/jumble_sender.php";
|
||||||
|
private Map<String, String> params;
|
||||||
|
|
||||||
|
JumbleSender(String username,long times , Response.Listener<String> listener) {
|
||||||
|
super(Method.POST, REQUEST_URL, listener, null);
|
||||||
|
params = new HashMap<>();
|
||||||
|
params.put("username", username);
|
||||||
|
params.put("jumble",times+"");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,9 +1,18 @@
|
||||||
package com.example.alzapp;
|
package com.example.alzapp;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
@ -22,6 +31,8 @@ public class QuickPlayMenu extends AppCompatActivity {
|
||||||
private Button game3;
|
private Button game3;
|
||||||
private Button game4;
|
private Button game4;
|
||||||
private long jumble_elapsed_millis = 0;
|
private long jumble_elapsed_millis = 0;
|
||||||
|
private String username;
|
||||||
|
private TextView username_text;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,8 +42,12 @@ public class QuickPlayMenu extends AppCompatActivity {
|
||||||
setContentView(R.layout.activity_quick_play_menu);
|
setContentView(R.layout.activity_quick_play_menu);
|
||||||
|
|
||||||
|
|
||||||
jumble = (Button) findViewById(R.id.jumble);
|
jumble = findViewById(R.id.jumble);
|
||||||
tilematch = (Button) findViewById(R.id.tilematch);
|
tilematch = findViewById(R.id.tilematch);
|
||||||
|
Intent intent = getIntent();
|
||||||
|
username = intent.getStringExtra(login.EXTRA_TEXT);
|
||||||
|
username_text = findViewById(R.id.username);
|
||||||
|
username_text.setText("username : "+ username);
|
||||||
|
|
||||||
jumble.setOnClickListener(new View.OnClickListener() {
|
jumble.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,6 +77,34 @@ public class QuickPlayMenu extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(jumble_elapsed_millis != 0) {
|
||||||
|
|
||||||
|
Response.Listener<String> responseListener = new Response.Listener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
try {
|
||||||
|
JSONObject jsonResponse = new JSONObject(response);
|
||||||
|
boolean success = jsonResponse.getBoolean("success");
|
||||||
|
if (success) {
|
||||||
|
Intent intent = new Intent(QuickPlayMenu.this, UserAreaActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(QuickPlayMenu.this);
|
||||||
|
builder.setMessage("Register Failed")
|
||||||
|
.setNegativeButton("Retry", null)
|
||||||
|
.create()
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
JumbleSender jumble_sender = new JumbleSender(username, jumble_elapsed_millis, responseListener);
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(QuickPlayMenu.this);
|
||||||
|
queue.add(jumble_sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Registerequest extends StringRequest {
|
public class Registerequest extends StringRequest {
|
||||||
private static final String REGISTER_REQUEST_URL = "https://eclectic-sweeps.000webhostapp.com/registration_enc.php";
|
private static final String REQUEST_URL = "https://eclectic-sweeps.000webhostapp.com/registration_enc.php";
|
||||||
private Map<String, String> params;
|
private Map<String, String> params;
|
||||||
|
|
||||||
Registerequest(String firstname, String lastname, String username, String dob, String email, String password, String gender, int age, Response.Listener<String> listener) {
|
Registerequest(String firstname, String lastname, String username, String dob, String email, String password, String gender, int age, Response.Listener<String> listener) {
|
||||||
super(Method.POST, REGISTER_REQUEST_URL, listener, null);
|
super(Method.POST, REQUEST_URL, listener, null);
|
||||||
params = new HashMap<>();
|
params = new HashMap<>();
|
||||||
params.put("username", username);
|
params.put("username", username);
|
||||||
params.put("password", password);
|
params.put("password", password);
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
package com.example.alzapp;
|
package com.example.alzapp;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import android.app.AlertDialog;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import org.json.*;
|
|
||||||
import java.lang.*;
|
import com.android.volley.RequestQueue;
|
||||||
import com.android.volley.*;
|
import com.android.volley.Response;
|
||||||
import com.android.volley.toolbox.*;
|
import com.android.volley.toolbox.Volley;
|
||||||
import android.app.AlertDialog;
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
/*******
|
/*******
|
||||||
Created on: 21/01/2020
|
Created on: 21/01/2020
|
||||||
|
|
||||||
|
@ -21,6 +25,7 @@ import android.app.AlertDialog;
|
||||||
********/
|
********/
|
||||||
|
|
||||||
public class login extends AppCompatActivity {
|
public class login extends AppCompatActivity {
|
||||||
|
public static final String EXTRA_TEXT = "com.example.alzapp.EXTRA_TEXT";
|
||||||
private TextView signup;
|
private TextView signup;
|
||||||
private Button signin;
|
private Button signin;
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,11 +78,13 @@ public class login extends AppCompatActivity {
|
||||||
boolean success = jsonResponse.getBoolean("success");
|
boolean success = jsonResponse.getBoolean("success");
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
String username1 = jsonResponse.getString("username");
|
String username = jsonResponse.getString("username");
|
||||||
|
|
||||||
|
|
||||||
Intent intent = new Intent(login.this, UserAreaActivity.class);
|
Intent intent = new Intent(login.this, QuickPlayMenu.class);
|
||||||
intent.putExtra("name", username1);
|
intent.putExtra(EXTRA_TEXT, username);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
login.this.startActivity(intent);
|
login.this.startActivity(intent);
|
||||||
|
|
|
@ -24,16 +24,19 @@
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
<include layout="@layout/backbutton"
|
<include
|
||||||
/>
|
android:id="@+id/include"
|
||||||
|
layout="@layout/backbutton"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
tools:layout_editor_absoluteX="0dp" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/tilematch"
|
android:id="@+id/tilematch"
|
||||||
android:background="@drawable/box_design"
|
|
||||||
android:layout_height="140dp"
|
|
||||||
android:layout_width="140dp"
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="140dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="36dp"
|
android:layout_marginEnd="36dp"
|
||||||
|
android:background="@drawable/box_design"
|
||||||
android:text="TILE MATCHING"
|
android:text="TILE MATCHING"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
|
@ -43,11 +46,11 @@
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/game4"
|
android:id="@+id/game4"
|
||||||
android:background="@drawable/box_design"
|
|
||||||
android:layout_width="140dp"
|
android:layout_width="140dp"
|
||||||
android:layout_height="140dp"
|
android:layout_height="140dp"
|
||||||
android:layout_marginTop="29dp"
|
android:layout_marginTop="29dp"
|
||||||
android:layout_marginEnd="36dp"
|
android:layout_marginEnd="36dp"
|
||||||
|
android:background="@drawable/box_design"
|
||||||
android:text="Game 4"
|
android:text="Game 4"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
|
@ -55,13 +58,26 @@
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tilematch"
|
app:layout_constraintTop_toBottomOf="@+id/tilematch"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/username"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
|
android:layout_marginVertical="@dimen/cardview_compat_inset_shadow"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingVertical="@dimen/activity_vertical_margin"
|
||||||
|
android:textSize="50dp"
|
||||||
|
tools:layout_editor_absoluteX="-26dp"
|
||||||
|
tools:layout_editor_absoluteY="520dp"
|
||||||
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/jumble"
|
android:id="@+id/jumble"
|
||||||
android:background="@drawable/box_design"
|
|
||||||
android:layout_width="140dp"
|
android:layout_width="140dp"
|
||||||
android:layout_height="140dp"
|
android:layout_height="140dp"
|
||||||
android:layout_marginStart="36dp"
|
android:layout_marginStart="36dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
android:background="@drawable/box_design"
|
||||||
android:text="JUMBLED WORDS"
|
android:text="JUMBLED WORDS"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
|
@ -73,11 +89,11 @@
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/game3"
|
android:id="@+id/game3"
|
||||||
android:background="@drawable/box_design"
|
|
||||||
android:layout_width="140dp"
|
android:layout_width="140dp"
|
||||||
android:layout_height="140dp"
|
android:layout_height="140dp"
|
||||||
android:layout_marginStart="36dp"
|
android:layout_marginStart="36dp"
|
||||||
android:layout_marginTop="29dp"
|
android:layout_marginTop="29dp"
|
||||||
|
android:background="@drawable/box_design"
|
||||||
android:text="Game 3"
|
android:text="Game 3"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
|
@ -86,5 +102,4 @@
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue