-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/week02 xml #3
base: develop-xml
Are you sure you want to change the base?
Changes from 10 commits
ef00a97
2d76926
20bedec
22db324
180cbfd
f735064
5f9bfa7
f63dbf9
0f45066
84688b5
c5b4502
64cd7d2
7c7ee7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,33 @@ | |
android:theme="@style/Theme.NOWSOPTAndroid" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:name=".Activity.HomeActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".Activity.SignUpActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".Activity.LoginActivity" | ||
android:exported="true"> | ||
|
||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
|
||
<activity | ||
android:name=".Activity.MainActivity" | ||
android:exported="false" /> | ||
|
||
<activity | ||
android:name=".Fragment.HomeFragment" | ||
android:exported="false"> | ||
|
||
</activity> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fragment๋ผ์ activity ํ๊ทธ๋ก ๋ฐ๋ก ์ ์ ์ํด์ฃผ์ ๋ ๋ ๊ฑฐ ๊ฐ์์! |
||
|
||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.sopt.now.Activity | ||
|
||
import android.os.Bundle | ||
import android.util.Log | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.Fragment | ||
import com.sopt.now.Fragment.HomeFragment | ||
import com.sopt.now.Fragment.MyPageFragment | ||
import com.sopt.now.Fragment.SearchFragment | ||
import com.sopt.now.R | ||
import com.sopt.now.databinding.ActivityHomeBinding | ||
class HomeActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityHomeBinding | ||
private val nameId="ID" | ||
private val namePassword = "PASSWORD" | ||
private val nameNickname = "NICKNAME" | ||
private val nameMbti = "MBTI" | ||
|
||
private lateinit var userId: String | ||
private lateinit var userPassword: String | ||
private lateinit var userNickname: String | ||
private lateinit var userMbti: String | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityHomeBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
Log.d("HomeActivity","HomeActivity onCreate") | ||
|
||
|
||
userId = intent.getStringExtra(nameId).toString() | ||
userPassword = intent.getStringExtra(namePassword).toString() | ||
userNickname = intent.getStringExtra(nameNickname).toString() | ||
userMbti = intent.getStringExtra(nameMbti).toString() | ||
|
||
clickBottomNavigation() | ||
|
||
val currentFragment = supportFragmentManager.findFragmentById(binding.fcvHome.id) | ||
if (currentFragment == null) { | ||
supportFragmentManager.beginTransaction() | ||
.add(binding.fcvHome.id, HomeFragment(userNickname)) | ||
.commit() | ||
} | ||
} | ||
|
||
private fun clickBottomNavigation() { | ||
binding.bnvHome.setOnItemSelectedListener { | ||
when (it.itemId) { | ||
R.id.menu_home -> { | ||
replaceFragment(HomeFragment(userNickname)) | ||
true | ||
} | ||
|
||
R.id.menu_search -> { | ||
replaceFragment(SearchFragment()) | ||
true | ||
} | ||
|
||
R.id.menu_mypage -> { | ||
replaceFragment(MyPageFragment(userId,userPassword,userNickname,userMbti)) | ||
true | ||
} | ||
|
||
else -> false | ||
} | ||
} | ||
} | ||
|
||
private fun replaceFragment(fragment: Fragment) { | ||
supportFragmentManager.beginTransaction() | ||
.replace(binding.fcvHome.id, fragment) | ||
.commit() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.sopt.now.Activity | ||
|
||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.util.Log | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.google.android.material.snackbar.Snackbar | ||
import com.sopt.now.databinding.ActivityLoginBinding | ||
|
||
class LoginActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityLoginBinding | ||
private val nameId="ID" | ||
private val namePassword = "PASSWORD" | ||
private val nameNickname = "NICKNAME" | ||
private val nameMbti = "MBTI" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์์๋ฅผ ๊ด๋ฆฌํ๋ ๋ ์ข์ ๋ฐฉ์์ด ์์ ๊ฒ ๊ฐ์ต๋๋ค ! |
||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityLoginBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
val id = intent.getStringExtra(nameId) | ||
val password = intent.getStringExtra(namePassword) | ||
val nickname = intent.getStringExtra(nameNickname) | ||
val mbti = intent.getStringExtra(nameMbti) | ||
|
||
|
||
binding.loginBtn.setOnClickListener { | ||
val enteredId = binding.editTextId.text.toString() | ||
val enteredPassword = binding.editTextPw.text.toString() | ||
|
||
when { | ||
enteredId != id -> { | ||
Snackbar.make( | ||
binding.root, | ||
"์์ด๋๋ฅผ ํ์ธํ์ธ์.", | ||
Snackbar.LENGTH_SHORT | ||
).show() | ||
} | ||
enteredPassword != password -> { | ||
Snackbar.make( | ||
binding.root, | ||
"๋น๋ฐ๋ฒํธ๋ฅผ ํ์ธํ์ธ์.", | ||
Snackbar.LENGTH_SHORT | ||
).show() | ||
} | ||
else -> { | ||
Log.d("Login Success","Login Success") | ||
val intentHome = Intent(this, HomeActivity::class.java).apply { | ||
putExtra(nameId, id) | ||
putExtra(namePassword, password) | ||
putExtra(nameNickname, nickname) | ||
putExtra(nameMbti, mbti) | ||
} | ||
Snackbar.make( | ||
binding.root, | ||
"๋ก๊ทธ์ธ ์ฑ๊ณต!", | ||
Snackbar.LENGTH_SHORT | ||
).show() | ||
startActivity(intentHome) | ||
|
||
} | ||
} | ||
|
||
} | ||
binding.goSignupBtn.setOnClickListener { | ||
val intentSignup = Intent(this, SignUpActivity::class.java) | ||
startActivity(intentSignup) | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.sopt.now.Activity | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.google.android.material.snackbar.Snackbar | ||
import com.sopt.now.R | ||
import com.sopt.now.databinding.ActivityMainBinding | ||
|
||
class MainActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityMainBinding | ||
private val nameId="ID" | ||
private val namePassword = "PASSWORD" | ||
private val nameNickname = "NICKNAME" | ||
private val nameMbti = "MBTI" | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityMainBinding.inflate(layoutInflater) //TODO: inflate ๋ ๋ฒ ํ๋ฉด ์ค๋ฅ ๊ณต๋ถ | ||
setContentView(binding.root) | ||
|
||
|
||
|
||
val id = intent.getStringExtra(nameId) | ||
val password = intent.getStringExtra(namePassword) | ||
val nickname = intent.getStringExtra(nameNickname) | ||
val mbti = intent.getStringExtra(nameMbti) | ||
|
||
Snackbar.make( | ||
binding.root, | ||
"๋ก๊ทธ์ธ ์ฑ๊ณต!", | ||
Snackbar.LENGTH_SHORT | ||
).show() | ||
|
||
|
||
binding.textNickname.text = getString(R.string.nickname,nickname) | ||
binding.textMbti.text = getString(R.string.mbti,mbti) | ||
binding.textId.text="$id" | ||
binding.textPw.text="$password" | ||
|
||
|
||
|
||
val mbtiImageName = mbti?.lowercase() + ".png" | ||
val mbtiImageId = mbtiImageName.let { resources.getIdentifier(it, "drawable", packageName) } | ||
// TODO: getIdentifier ๋ง๊ณ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ํ์ผ ์ฐพ์๋ณด๊ธฐ | ||
if (mbtiImageId != 0) { | ||
binding.imageMbti.setImageResource(mbtiImageId) | ||
|
||
} | ||
|
||
val mbtiDescriptionMap = mapOf( | ||
"ISFP" to R.string.isfp, | ||
"ISFJ" to R.string.isfj, | ||
"ISTP" to R.string.istp, | ||
"ISTJ" to R.string.istj, | ||
"INFP" to R.string.infp, | ||
"INFJ" to R.string.infj, | ||
"INTP" to R.string.intp, | ||
"INTJ" to R.string.intj, | ||
"ESFP" to R.string.esfp, | ||
"ESFJ" to R.string.esfj, | ||
"ESTP" to R.string.estp, | ||
"ESTJ" to R.string.estj, | ||
"ENFP" to R.string.enfp, | ||
"ENFJ" to R.string.enfj, | ||
"ENTP" to R.string.entp, | ||
"ENTJ" to R.string.entj | ||
|
||
) | ||
|
||
val mbtiDescriptionResId = mbti?.let { mbtiDescriptionMap[it] } | ||
|
||
|
||
val mbtiDescription = mbtiDescriptionResId?.let { getString(it) } ?: getString(R.string.default_description) | ||
|
||
binding.textMbtiDes.text = mbtiDescription | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.sopt.now.Activity | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.google.android.material.snackbar.Snackbar | ||
import com.sopt.now.databinding.ActivitySignUpBinding | ||
|
||
class SignUpActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivitySignUpBinding | ||
private val nameId="ID" | ||
private val namePassword = "PASSWORD" | ||
private val nameNickname = "NICKNAME" | ||
private val nameMbti = "MBTI" | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivitySignUpBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
|
||
binding.signupBtn.setOnClickListener { | ||
val mbtiInput = binding.editTextMbti.text.toString().uppercase() | ||
|
||
val id = binding.editTextId.text.toString() | ||
val password = binding.editTextPw.text.toString() | ||
val nickname = binding.editTextNn.text.toString() | ||
val mbti = binding.editTextMbti.text.toString().uppercase() | ||
|
||
when { | ||
id.length !in 6..10 -> { | ||
Snackbar.make( | ||
binding.root, | ||
"ID๋ 6~10๊ธ์์ฌ์ผ ํฉ๋๋ค.", | ||
Snackbar.LENGTH_SHORT | ||
).show() | ||
} | ||
password.length !in 8..12 -> { | ||
Snackbar.make( | ||
binding.root, | ||
"Password๋ 8~12๊ธ์์ฌ์ผ ํฉ๋๋ค.", | ||
Snackbar.LENGTH_SHORT | ||
).show() | ||
} | ||
nickname.isEmpty() -> { | ||
Snackbar.make( | ||
binding.root, | ||
"๋๋ค์์ ํ ๊ธ์ ์ด์์ด์ด์ผ ํฉ๋๋ค.", | ||
Snackbar.LENGTH_SHORT | ||
).show() | ||
} | ||
mbtiInput.length != 4 || !validMBTI(mbtiInput) -> { | ||
Snackbar.make( | ||
binding.root, | ||
"MBTI ํ์์ด ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค. (E/I, S/N, F/T, P/J)", | ||
Snackbar.LENGTH_SHORT | ||
).show() | ||
} | ||
else -> { | ||
val intent = Intent(this, LoginActivity::class.java).apply { | ||
putExtra(nameId, id) | ||
putExtra(namePassword, password) | ||
putExtra(nameNickname, nickname) | ||
putExtra(nameMbti, mbti) | ||
} | ||
Snackbar.make( | ||
binding.root, | ||
"ํ์๊ฐ์ ์ฑ๊ณต", | ||
Snackbar.LENGTH_SHORT | ||
).show() | ||
startActivity(intent) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ด๋ ๊ฒ ๋ก๊ทธ์ธ ์กํฐ๋นํฐ๋ก ์ด๋ํ๋ค, ๋ก๊ทธ์ธ ์กํฐ๋นํฐ์์ ๋ค๋ก๊ฐ๊ธฐ ๋ฒํผ์ ๋๋ฅด๋ฉด ์ด๋ป๊ฒ ๋ ๊น์? |
||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun validMBTI(mbti:String):Boolean{ | ||
val validMBTIPattern = Regex("[EI][SN][TF][JP]") | ||
return validMBTIPattern.matches(mbti) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํน์ ์ด ๋ถ๋ถ์ ์ ๋ชป ๋ค์ด๊ฐ ๊ฑด๊ฐ์??