-
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.
Merge branch 'feature/1-login_signup_ui' of https://github.com/EarthG…
…ardener/EarthGardener-Android into feature/13-User_View_Logic
- Loading branch information
Showing
15 changed files
with
721 additions
and
4 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
43 changes: 43 additions & 0 deletions
43
...rdener/app/src/main/java/team/gdsc/earthgardener/presentation/user/login/LoginActivity.kt
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,43 @@ | ||
package team.gdsc.earthgardener.presentation.user.login | ||
|
||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen | ||
import android.os.Bundle | ||
import android.widget.Toast | ||
import team.gdsc.earthgardener.R | ||
import team.gdsc.earthgardener.databinding.ActivityLoginBinding | ||
import team.gdsc.earthgardener.presentation.MainActivity | ||
import team.gdsc.earthgardener.presentation.base.BaseActivity | ||
import team.gdsc.earthgardener.presentation.user.signup.SignUpActivity | ||
|
||
class LoginActivity : BaseActivity<ActivityLoginBinding>(R.layout.activity_login) { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
installSplashScreen() | ||
super.onCreate(savedInstanceState) | ||
btnLoginEvent() | ||
navigateToSignUp() | ||
} | ||
|
||
private fun btnLoginEvent(){ | ||
binding.btnLogin.setOnClickListener { | ||
val email = binding.etLoginEmail.text.toString() | ||
val pw = binding.etLoginPw.text.toString() | ||
// Post Login | ||
|
||
navigateToMain() | ||
} | ||
} | ||
|
||
private fun navigateToSignUp(){ | ||
binding.tvLoginSignUp.setOnClickListener { | ||
startActivity(Intent(this, SignUpActivity::class.java)) | ||
} | ||
} | ||
|
||
private fun navigateToMain(){ | ||
startActivity(Intent(this, MainActivity::class.java)) | ||
finish() | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ener/app/src/main/java/team/gdsc/earthgardener/presentation/user/signup/SignUpActivity.kt
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,29 @@ | ||
package team.gdsc.earthgardener.presentation.user.signup | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import team.gdsc.earthgardener.R | ||
import team.gdsc.earthgardener.databinding.ActivitySignUpBinding | ||
import team.gdsc.earthgardener.presentation.base.BaseActivity | ||
import team.gdsc.earthgardener.presentation.user.signup.emailpw.EmailPwFragment | ||
|
||
class SignUpActivity : BaseActivity<ActivitySignUpBinding>(R.layout.activity_sign_up) { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setSignUpFragment() | ||
} | ||
|
||
private fun setSignUpFragment(){ | ||
supportFragmentManager.beginTransaction() | ||
.add(R.id.frame_sign_up, EmailPwFragment()) | ||
.commit() | ||
} | ||
|
||
fun nextSignUpFragment(fa: Fragment){ | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.frame_sign_up, fa) | ||
.commit() | ||
} | ||
|
||
} |
117 changes: 117 additions & 0 deletions
117
...src/main/java/team/gdsc/earthgardener/presentation/user/signup/emailpw/EmailPwFragment.kt
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,117 @@ | ||
package team.gdsc.earthgardener.presentation.user.signup.emailpw | ||
|
||
import android.os.Bundle | ||
import android.text.Editable | ||
import android.text.TextWatcher | ||
import android.view.View | ||
import androidx.core.content.ContextCompat | ||
import androidx.core.view.isVisible | ||
import team.gdsc.earthgardener.R | ||
import team.gdsc.earthgardener.databinding.FragmentEmailPwBinding | ||
import team.gdsc.earthgardener.presentation.base.BaseFragment | ||
import team.gdsc.earthgardener.presentation.user.signup.nickname.NickNameFragment | ||
import team.gdsc.earthgardener.presentation.user.signup.SignUpActivity | ||
import java.util.regex.Pattern | ||
|
||
class EmailPwFragment : BaseFragment<FragmentEmailPwBinding>(R.layout.fragment_email_pw) { | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
checkEmailPattern() | ||
checkEmailWatcher() | ||
getCodeEvent() | ||
checkCode() | ||
etPasswordWatcher() | ||
btnNextEvent() | ||
} | ||
|
||
private fun checkEmailPattern(): Boolean{ | ||
val email = binding.etSignUpEmail.text.toString().trim() | ||
val emailValidation = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$" | ||
val p = Pattern.matches(emailValidation, email) | ||
return if(p){ | ||
binding.etSignUpEmail.setTextColor(ContextCompat.getColor(context!!, R.color.text_black)) | ||
true | ||
}else{ | ||
binding.etSignUpEmail.setTextColor(ContextCompat.getColor(context!!, R.color.accent_pink)) | ||
false | ||
} | ||
} | ||
|
||
private fun checkEmailWatcher(){ | ||
binding.etSignUpEmail.addTextChangedListener(object: TextWatcher{ | ||
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | ||
|
||
} | ||
|
||
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | ||
|
||
} | ||
|
||
override fun afterTextChanged(p0: Editable?) { | ||
checkEmailPattern() | ||
} | ||
|
||
}) | ||
} | ||
|
||
private fun getCodeEvent(){ | ||
binding.tvGetCode.setOnClickListener { | ||
if(checkEmailPattern()){ | ||
// Get Code from email | ||
|
||
|
||
binding.tvCode.isVisible = true | ||
binding.linearEmailCode.isVisible = true | ||
} | ||
} | ||
} | ||
|
||
private fun checkCode(){ | ||
binding.tvCheckCode.setOnClickListener { | ||
// check if code is right | ||
} | ||
} | ||
|
||
private fun etPasswordWatcher(){ | ||
binding.etSignupPw.addTextChangedListener(object: TextWatcher{ | ||
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | ||
|
||
} | ||
|
||
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | ||
btnNextActive() | ||
} | ||
|
||
override fun afterTextChanged(p0: Editable?) { | ||
|
||
} | ||
|
||
}) | ||
} | ||
|
||
private fun btnNextActive(){ | ||
val signUpActivity = activity as SignUpActivity | ||
|
||
if(binding.etSignupPw.text.isNotEmpty() ){ // 이메일 인증 코드 맞는지 여부 조건도 넣기 | ||
signUpActivity.binding.btnNext.setBackgroundResource(R.drawable.rectangle_primary_green_radius_30) | ||
signUpActivity.binding.btnNext.isEnabled = true | ||
}else{ | ||
signUpActivity.binding.btnNext.setBackgroundResource(R.drawable.rectangle_light_gray_radius_30) | ||
signUpActivity.binding.btnNext.isEnabled = false | ||
} | ||
} | ||
|
||
private fun btnNextEvent(){ | ||
val signUpActivity = activity as SignUpActivity | ||
signUpActivity.binding.btnNext.setOnClickListener { | ||
signUpActivity.binding.btnNext.text = getString(R.string.finish) | ||
signUpActivity.binding.btnNext.setBackgroundResource(R.drawable.rectangle_light_gray_radius_30) | ||
signUpActivity.binding.btnNext.isEnabled = false | ||
signUpActivity.nextSignUpFragment(NickNameFragment()) | ||
} | ||
} | ||
|
||
|
||
|
||
} |
108 changes: 108 additions & 0 deletions
108
...c/main/java/team/gdsc/earthgardener/presentation/user/signup/nickname/NickNameFragment.kt
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,108 @@ | ||
package team.gdsc.earthgardener.presentation.user.signup.nickname | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.graphics.Bitmap | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.provider.MediaStore | ||
import android.text.Editable | ||
import android.text.TextWatcher | ||
import android.view.View | ||
import okhttp3.MediaType | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.MultipartBody | ||
import okhttp3.RequestBody | ||
import okio.BufferedSink | ||
import team.gdsc.earthgardener.R | ||
import team.gdsc.earthgardener.databinding.FragmentNickNameBinding | ||
import team.gdsc.earthgardener.presentation.base.BaseFragment | ||
import team.gdsc.earthgardener.presentation.user.signup.SignUpActivity | ||
import java.lang.Exception | ||
|
||
class NickNameFragment : BaseFragment<FragmentNickNameBinding>(R.layout.fragment_nick_name) { | ||
|
||
private val OPEN_GALLERY = 1 | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
openGallery() | ||
btnFinishActive() | ||
btnFinishEvent() | ||
} | ||
|
||
private fun openGallery(){ | ||
binding.ivSignupUser.setOnClickListener { | ||
val intent = Intent(Intent.ACTION_GET_CONTENT) | ||
intent.type = "image/*" | ||
startActivityForResult(intent, OPEN_GALLERY) | ||
} | ||
} | ||
|
||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | ||
super.onActivityResult(requestCode, resultCode, data) | ||
if(resultCode == Activity.RESULT_OK){ | ||
if(requestCode == OPEN_GALLERY){ | ||
val currentImageUrl: Uri? = data?.data | ||
try{ | ||
val bitmap = MediaStore.Images.Media.getBitmap(activity?.contentResolver, currentImageUrl) | ||
binding.ivSignupUser.setImageBitmap(bitmap) | ||
changeToMultipart(bitmap) | ||
}catch (e: Exception){ | ||
e.printStackTrace() | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun changeToMultipart(bitmap: Bitmap){ | ||
val bitmapRequestBody = BitmapRequestBody(bitmap) | ||
val bitmapMultipartBody: MultipartBody.Part = | ||
MultipartBody.Part.createFormData("image", ".jpeg", bitmapRequestBody) | ||
|
||
// Post bitmapMultipartBody | ||
} | ||
|
||
inner class BitmapRequestBody(private val bitmap: Bitmap): RequestBody(){ | ||
override fun contentType(): MediaType = "image/jpeg".toMediaType() | ||
|
||
override fun writeTo(sink: BufferedSink) { | ||
bitmap.compress(Bitmap.CompressFormat.JPEG, 99, sink.outputStream()) | ||
} | ||
|
||
} | ||
|
||
private fun btnFinishActive(){ | ||
binding.etSignUpNickname.addTextChangedListener(object: TextWatcher{ | ||
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | ||
|
||
} | ||
|
||
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | ||
val signUpActivity = activity as SignUpActivity | ||
if(binding.etSignUpNickname.text.isNotEmpty()){ | ||
signUpActivity.binding.btnNext.setBackgroundResource(R.drawable.rectangle_primary_green_radius_30) | ||
signUpActivity.binding.btnNext.isEnabled = true | ||
}else{ | ||
signUpActivity.binding.btnNext.setBackgroundResource(R.drawable.rectangle_light_gray_radius_30) | ||
signUpActivity.binding.btnNext.isEnabled = false | ||
} | ||
} | ||
|
||
override fun afterTextChanged(p0: Editable?) { | ||
|
||
} | ||
|
||
}) | ||
} | ||
|
||
private fun btnFinishEvent(){ | ||
// Post SignUp | ||
|
||
|
||
val signUpActivity = activity as SignUpActivity | ||
signUpActivity.binding.btnNext.setOnClickListener { | ||
signUpActivity.finish() | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
EarthGardener/app/src/main/res/drawable/rectangle_light_gray_radius_30.xml
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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid | ||
android:color="@color/any_light_gray"/> | ||
<corners | ||
android:radius="30dp"/> | ||
|
||
</shape> |
7 changes: 7 additions & 0 deletions
7
EarthGardener/app/src/main/res/drawable/rectangle_light_gray_width_1.xml
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<stroke | ||
android:color="@color/any_light_gray" | ||
android:width="1dp"/> | ||
</shape> |
8 changes: 8 additions & 0 deletions
8
EarthGardener/app/src/main/res/drawable/rectangle_primary_green_radius_30.xml
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,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid | ||
android:color="@color/primary_green"/> | ||
<corners | ||
android:radius="30dp"/> | ||
</shape> |
Oops, something went wrong.