-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b1692d
commit b5a1ecc
Showing
10 changed files
with
390 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/src/main/java/com/dsm2018/get_terra_android_v2/KeyCertifiedActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.dsm2018.get_terra_android_v2; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import com.dsm2018.get_terra_android_v2.Connector.API; | ||
import com.dsm2018.get_terra_android_v2.Connector.ServiceGenerator; | ||
import com.google.gson.JsonObject; | ||
|
||
import retrofit2.Call; | ||
import retrofit2.Callback; | ||
import retrofit2.Response; | ||
|
||
public class KeyCertifiedActivity extends AppCompatActivity { | ||
TextView ID; | ||
EditText keytoken; | ||
Button joingame; | ||
String getKeytoken; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.acitivty_keycertified); | ||
|
||
keytoken = (EditText) findViewById(R.id.keytoken_et); | ||
joingame = (Button) findViewById(R.id.certificate_btn); | ||
joingame.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
getKeytoken = keytoken.getText().toString(); | ||
getKeytoken = getKeytoken.trim(); | ||
if (getKeytoken.getBytes().length <= 0) { | ||
Toast.makeText(getApplicationContext(), "이메일 혹은 인증번호가 입력되지 않았습니다", Toast.LENGTH_SHORT).show(); | ||
} else { | ||
post(); | ||
} | ||
|
||
} | ||
}); | ||
} | ||
|
||
public void post() { | ||
API retrofit = ServiceGenerator.getClient().create(API.class); | ||
JsonObject jsonObject = new JsonObject(); | ||
jsonObject.addProperty("gameKey", getKeytoken); | ||
Call<Void> call = retrofit.key_certified(jsonObject); | ||
call.enqueue(new Callback<Void>() { | ||
@Override | ||
public void onResponse(Call<Void> call, Response<Void> response) { | ||
Void repo = response.body(); | ||
if (response.code()==201) { | ||
Intent intent = new Intent(getApplicationContext(), MainActivity.class); | ||
startActivity(intent); | ||
} | ||
else if(response.code()==204) { | ||
Toast.makeText(getApplicationContext(), "인증번호를 잘못 입력하셨습니다.", Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onFailure(Call<Void> call, Throwable t) { | ||
|
||
} | ||
}); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
app/src/main/java/com/dsm2018/get_terra_android_v2/SignUpActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.dsm2018.get_terra_android_v2; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
import com.dsm2018.get_terra_android_v2.Connector.API; | ||
import com.dsm2018.get_terra_android_v2.Connector.ServiceGenerator; | ||
import com.google.gson.JsonObject; | ||
|
||
import retrofit2.Call; | ||
import retrofit2.Callback; | ||
import retrofit2.Response; | ||
|
||
public class SignUpActivity extends AppCompatActivity { | ||
EditText email; | ||
EditText ID; | ||
EditText password; | ||
String getEmail; | ||
String getID; | ||
String getPassword; | ||
Button signup_btn; | ||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_signup); | ||
|
||
final String mail = "^[_a-zA-Z0-9-\\.]+@[\\.a-zA-Z0-9-]+\\.[a-zA-Z]+$"; | ||
signup_btn = (Button) findViewById(R.id.signup_btn); | ||
email = findViewById(R.id.email_et); | ||
ID = findViewById(R.id.id_et); | ||
password = findViewById(R.id.password_et); | ||
signup_btn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
getEmail = email.getText().toString(); | ||
getID = ID.getText().toString(); | ||
getPassword = password.getText().toString(); | ||
if (getEmail.getBytes().length <= 0 | getID.getBytes().length <= 0 | getPassword.getBytes().length <= 0) { | ||
Toast.makeText(getApplicationContext(), "입력이 완료되지 않았습니다", Toast.LENGTH_SHORT).show(); | ||
} | ||
else if (getID.matches(mail)) { | ||
Toast.makeText(getApplicationContext(), "이메일 형식이 잘못되었습니다.", Toast.LENGTH_SHORT).show(); | ||
} | ||
else { | ||
post(); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
public void post() { | ||
API retrofit = ServiceGenerator.getClient().create(API.class); | ||
JsonObject jsonObject = new JsonObject(); | ||
jsonObject.addProperty("email", getEmail); | ||
jsonObject.addProperty("id",getID); | ||
jsonObject.addProperty("password", getPassword); | ||
Call<Void> call = retrofit.key_certified(jsonObject); | ||
call.enqueue(new Callback<Void>() { | ||
@Override | ||
public void onResponse(Call<Void> call, Response<Void> response) { | ||
Void repo = response.body(); | ||
if (response.code() == 205) { | ||
Toast.makeText(getApplicationContext(), "중복된 아이디입니다.", Toast.LENGTH_SHORT).show(); | ||
} | ||
else{ | ||
Toast.makeText(getApplicationContext(), "회원가입이 완료되었습니다.", Toast.LENGTH_SHORT).show(); | ||
Intent intent = new Intent(getApplicationContext(), LoginActivity.class); | ||
startActivity(intent); | ||
} | ||
} | ||
|
||
@Override | ||
public void onFailure(Call<Void> call, Throwable t) { | ||
|
||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="#FFDBA5"/> | ||
<corners android:radius="32dp"/> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
tools:context=".KeyCertifiedActivity"> | ||
|
||
<ImageView | ||
android:id="@+id/back_top" | ||
android:layout_width="match_parent" | ||
android:layout_height="223dp" | ||
android:background="@drawable/back_ellipse_default" /> | ||
|
||
<ImageView | ||
android:id="@+id/logo" | ||
android:layout_width="153dp" | ||
android:layout_height="141dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="135dp" | ||
android:src="@drawable/getterra_logo" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/id_et" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="20dp" | ||
android:layout_marginStart="20dp" | ||
android:layout_marginTop="30dp" | ||
android:gravity="center" | ||
android:text="안녕하세요 ID님" | ||
android:textSize="37sp" | ||
android:textColor="#ffdba5" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/logo" /> | ||
|
||
<EditText | ||
android:id="@+id/keytoken_et" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="20dp" | ||
android:layout_marginStart="20dp" | ||
android:layout_marginTop="50dp" | ||
android:hint="인증코드를 입력해주세요" | ||
android:textSize="19sp" | ||
android:textColorHint="#ffdba5" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/id_et" /> | ||
|
||
<Button | ||
android:id="@+id/certificate_btn" | ||
android:layout_width="match_parent" | ||
android:layout_height="48dp" | ||
android:layout_marginBottom="40dp" | ||
android:layout_marginEnd="20dp" | ||
android:layout_marginStart="20dp" | ||
android:background="@drawable/back_btn_signup" | ||
android:text="Join Game" | ||
android:textColor="#ffb587" | ||
android:textSize="28sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
</android.support.constraint.ConstraintLayout> |
Oops, something went wrong.