Skip to content

Commit

Permalink
Merge pull request #29 from ILoveGameCoding/master
Browse files Browse the repository at this point in the history
U.O.F-Mobile 사용자별 회원가입 기능 구현
  • Loading branch information
ByteAurora authored Aug 5, 2021
2 parents 0a8d5b5 + ff21f69 commit 97ba720
Show file tree
Hide file tree
Showing 23 changed files with 910 additions and 649 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/com/uof/uof_mobile/LobbyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class LobbyActivity extends AppCompatActivity {
Expand Down
277 changes: 19 additions & 258 deletions app/src/main/java/com/uof/uof_mobile/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,150 +93,6 @@ public void afterTextChanged(Editable editable) {
}
});

/*
// 회원가입 - 이름 입력란이 수정되었을 경우
tilLoginRegisterName.getEditText().addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
int result = checkRegisterName(editable.toString());
if (result == Constants.Pattern.NOT_ALLOWED_CHARACTER) {
tilLoginRegisterName.setErrorEnabled(true);
tilLoginRegisterName.setError("이름은 한글만 가능합니다");
} else {
tilLoginRegisterName.setErrorEnabled(false);
tilLoginRegisterName.setError(null);
}
btnLoginRegister.setEnabled(checkRegister());
}
});
// 회원가입 - 아이디 입력란이 수정되었을 경우
tilLoginRegisterId.getEditText().addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
int result = checkRegisterId(editable.toString());
if (result == Constants.Pattern.LENGTH_SHORT) {
tilLoginRegisterId.setErrorEnabled(true);
tilLoginRegisterId.setError("아이디는 8자리 이상이어야 합니다");
} else if (result == Constants.Pattern.NOT_ALLOWED_CHARACTER) {
tilLoginRegisterId.setErrorEnabled(true);
tilLoginRegisterId.setError("알파벳, 숫자, !@#*만 사용할 수 있습니다");
} else {
tilLoginRegisterId.setErrorEnabled(false);
tilLoginRegisterId.setError(null);
}
btnLoginRegister.setEnabled(checkRegister());
}
});
// 회원가입 - 비밀번호 입력란이 수정되었을 경우
tilLoginRegisterPw.getEditText().addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
int result = checkRegisterPw(editable.toString());
if (result == Constants.Pattern.LENGTH_SHORT) {
tilLoginRegisterPw.setErrorEnabled(true);
tilLoginRegisterPw.setError("비밀번호는 8자리 이상이어야 합니다");
} else if (result == Constants.Pattern.NOT_ALLOWED_CHARACTER) {
tilLoginRegisterPw.setErrorEnabled(true);
tilLoginRegisterPw.setError("알파벳, 숫자, !@#*만 사용할 수 있습니다");
} else {
tilLoginRegisterPw.setErrorEnabled(false);
tilLoginRegisterPw.setError(null);
}
if (!editable.toString().equals(tilLoginRegisterPwChk.getEditText().getText().toString())) {
tilLoginRegisterPw.setErrorEnabled(true);
tilLoginRegisterPwChk.setError("비밀번호가 일치하지 않습니다");
} else {
tilLoginRegisterPw.setErrorEnabled(false);
tilLoginRegisterPwChk.setError(null);
}
btnLoginRegister.setEnabled(checkRegister());
}
});
// 회원가입 - 비밀번호 재확인 입력란이 수정되었을 경우
tilLoginRegisterPwChk.getEditText().addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (!editable.toString().equals(tilLoginRegisterPw.getEditText().getText().toString())) {
tilLoginRegisterPwChk.setErrorEnabled(true);
tilLoginRegisterPwChk.setError("비밀번호가 일치하지 않습니다");
btnLoginRegister.setEnabled(false);
} else {
tilLoginRegisterPwChk.setErrorEnabled(false);
tilLoginRegisterPwChk.setError(null);
btnLoginRegister.setEnabled(checkRegister());
}
}
});
// 회원가입 - 전화번호 입력란이 수정되었을 경우
tilLoginRegisterPhoneNumber.getEditText().addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
int result = checkRegisterPhoneNumber(editable.toString());
if(result == Constants.Pattern.LENGTH_SHORT || result == Constants.Pattern.NOT_ALLOWED_CHARACTER){
tilLoginRegisterPhoneNumber.setErrorEnabled(true);
tilLoginRegisterPhoneNumber.setError("전화번호 형식이 맞지 않습니다");
} else{
tilLoginRegisterPhoneNumber.setErrorEnabled(false);
tilLoginRegisterPhoneNumber.setError(null);
}
btnLoginRegister.setEnabled(checkRegister());
}
});
*/

// 로그인 버튼이 눌렸을 경우
btnLoginLogin.setOnClickListener(view -> {
btnLoginLogin.setEnabled(false);
Expand Down Expand Up @@ -279,129 +135,34 @@ public void afterTextChanged(Editable editable) {
btnLoginLogin.setEnabled(true);
});

/*
// 회원가입 버튼이 눌렸을 경우
btnLoginRegister.setOnClickListener(view -> {
// 회원가입 창일 경우
try {
JSONObject sendData = new JSONObject();
sendData.put("request_code", "1001");
JSONObject message = new JSONObject();
message.put("id", tilLoginRegisterId.getEditText().getText().toString());
message.put("pw", tilLoginRegisterPw.getEditText().getText().toString());
message.put("name", tilLoginRegisterName.getEditText().getText().toString());
message.put("phone", tilLoginRegisterPhoneNumber.getEditText().getText().toString());
sendData.putOpt("message", message);
JSONObject recvData = new JSONObject(new HttpManager().execute(new String[]{"http://" + Constants.Network.EXTERNAL_SERVER_IP + ":" + Constants.Network.EXTERNAL_SERVER_PORT, sendData.toString()}).get());
String requestCode = recvData.getString("request_code");
if (requestCode.equals("0001")) {
// 회원가입 성공 - 로그인창 표시
llLoginLoginLayout.setVisibility(View.VISIBLE);
llLoginRegisterLayout.setVisibility(View.GONE);
} else if (requestCode.equals("0002")) {
// 회원가입 실패 - 아이디 중복
tilLoginRegisterId.setErrorEnabled(true);
tilLoginRegisterId.setError("해당 아이디는 이미 사용중입니다");
} else {
// 회원가입 실패 - 기타 오류
Toast.makeText(LoginActivity.this, "회원가입 실패: " + recvData.toString(), Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(LoginActivity.this, e.toString(), Toast.LENGTH_LONG).show();
}
});
*/

// 회원가입 TextView가 눌렸을 경우
tvLoginRegister.setOnClickListener(view -> {
new RegisterTypeDialog(LoginActivity.this, true, true,
new RegisterTypeDialogListener() {
@Override
public void onCustomerClick() {
Toast.makeText(LoginActivity.this, "일반 고객", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
intent.putExtra("RegisterType", 1); //고객
startActivity(intent); //다음 activity로 넘어가기
}

@Override
public void onUofPartnerClick() {
Toast.makeText(LoginActivity.this, "U.O.F 파트너", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
intent.putExtra("RegisterType", 2); //파트너
startActivity(intent); //다음 activity로 넘어가기
}

@Override
public void onCancelClick() {

}
}).show();
@Override
public void onCustomerClick() {
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
intent.putExtra("RegisterType", 0); //고객
startActivity(intent); //다음 activity로 넘어가기
}

@Override
public void onUofPartnerClick() {
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
intent.putExtra("RegisterType", 1); //파트너
startActivity(intent); //다음 activity로 넘어가기
}

@Override
public void onCancelClick() {

}
}).show();
});
}

// 로그인 시 아이디, 비밀번호 입력란 확인
private boolean checkLogin() {
return tilLoginId.getEditText().getText().toString().length() > 0 && tilLoginPw.getEditText().getText().toString().length() > 0;
}

/*
// 회원가입 시 아이디, 비밀번호, 이름, 전화번호 확인
private boolean checkRegister() {
return checkRegisterId(tilLoginRegisterId.getEditText().getText().toString()) == Constants.Pattern.OK
&& checkRegisterPw(tilLoginRegisterPw.getEditText().getText().toString()) == Constants.Pattern.OK
&& checkRegisterName(tilLoginRegisterName.getEditText().getText().toString()) == Constants.Pattern.OK
&& checkRegisterPhoneNumber(tilLoginRegisterPhoneNumber.getEditText().getText().toString()) == Constants.Pattern.OK;
}
// 회원가입 - 아이디 패턴 및 보안 확인
private int checkRegisterId(String id) {
if (id.length() < 8) {
return Constants.Pattern.LENGTH_SHORT;
} else if (!java.util.regex.Pattern.matches("^[a-zA-Z0-9@!*#]+$", id)) {
return Constants.Pattern.NOT_ALLOWED_CHARACTER;
} else {
return Constants.Pattern.OK;
}
}
// 회원가입 - 비밀번호 패턴 및 보안 확인
private int checkRegisterPw(String pw) {
if (pw.length() < 8) {
return Constants.Pattern.LENGTH_SHORT;
} else if (!java.util.regex.Pattern.matches("^[a-zA-Z0-9@!*#]+$", pw)) {
return Constants.Pattern.NOT_ALLOWED_CHARACTER;
} else {
return Constants.Pattern.OK;
}
}
// 회원가입 - 이름 패턴 확인
private int checkRegisterName(String name) {
if (name.length() == 0) {
return Constants.Pattern.LENGTH_SHORT;
} else if (!java.util.regex.Pattern.matches("^[ㄱ-ㅎ가-힣]+$", name)) {
return Constants.Pattern.NOT_ALLOWED_CHARACTER;
} else {
return Constants.Pattern.OK;
}
}
// 회원가입 - 전화번호 패턴 확인
private int checkRegisterPhoneNumber(String phoneNumber) {
if (phoneNumber.length() < 11) {
return Constants.Pattern.LENGTH_SHORT;
} else if (!java.util.regex.Pattern.matches("^[0-9]+$", phoneNumber)) {
return Constants.Pattern.NOT_ALLOWED_CHARACTER;
} else {
return Constants.Pattern.OK;
}
}
*/
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/uof/uof_mobile/OwnerLobbyActivity.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.uof.uof_mobile;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class OwnerLobbyActivity extends AppCompatActivity {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.uof.uof_mobile;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class OwnerQRRecognitionActivity extends AppCompatActivity {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.uof.uof_mobile;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class OwnerSettingActivity extends AppCompatActivity {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

public class QRRecognitionActivity extends AppCompatActivity {
private IntentIntegrator QRscan;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -26,8 +27,8 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if(result != null) {
if(result.getContents() == null) {
if (result != null) {
if (result.getContents() == null) {
Toast.makeText(this, "실패", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "성공: " + result.getContents(), Toast.LENGTH_LONG).show();
Expand Down
Loading

0 comments on commit 97ba720

Please sign in to comment.