Skip to content
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

부산대Android_이창욱_1주차_과제 #5

Open
wants to merge 33 commits into
base: ichanguk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2c98399
docs: update README.md
ichanguk Jun 24, 2024
25b465c
design: add EditText UI For name and phone num
ichanguk Jun 24, 2024
baea888
design: add Cancel Button And Save Button UI
ichanguk Jun 24, 2024
3e5fb42
feat: update Save Button Feature
ichanguk Jun 24, 2024
f8f79dc
feat: restrict the input of Phone Num EditText
ichanguk Jun 24, 2024
4caafd6
refactor: place the EditTexts inside a LinearLayout
ichanguk Jun 24, 2024
f18b859
design: add EditText UI
ichanguk Jun 25, 2024
3f00cf0
design: add see more layout UI
ichanguk Jun 25, 2024
57f1e73
feat: update See More Feature
ichanguk Jun 25, 2024
4d753c0
design: change Gender EditText
ichanguk Jun 25, 2024
886e1ec
feat: update Save Button Feature
ichanguk Jun 25, 2024
3e22983
feat: update Cancel Button Feature
ichanguk Jun 25, 2024
ca37ded
feat: update Input Gender Feature
ichanguk Jun 25, 2024
07e0a92
docs: update README.md
ichanguk Jun 25, 2024
6df13cf
feat: update Input Birthday Feature
ichanguk Jun 25, 2024
ebcc94c
design: add ScrollView UI
ichanguk Jun 25, 2024
d5ea270
docs: update README.md
ichanguk Jun 26, 2024
b9363d6
design: design Register Activity
ichanguk Jun 26, 2024
b4bdadf
feat: update Activity Transition feature
ichanguk Jun 26, 2024
9583c7f
design: add Contact List UI
ichanguk Jun 26, 2024
d984a5f
docs: update README.md
ichanguk Jun 26, 2024
24fda26
feat: update Register Contact Feature
ichanguk Jun 26, 2024
9d96221
comment: add Function Comment
ichanguk Jun 27, 2024
1448519
feat: update Save Restore Feature
ichanguk Jun 27, 2024
177dd14
design: design Detail Activity
ichanguk Jun 27, 2024
24832c6
feat: update Detail Activity Feature
ichanguk Jun 27, 2024
17cd7d4
docs: update README.md
ichanguk Jun 27, 2024
239de5c
feat: update Show AlertDialog feature
ichanguk Jun 27, 2024
f4945cf
refactor: Apply ktlint formatting rules
ichanguk Jun 27, 2024
50311b0
chore: add Images for README.md
ichanguk Jun 27, 2024
b5394e8
docs: update README.md
ichanguk Jun 27, 2024
c27935f
refactor: refactor Setting Visibility
ichanguk Jul 2, 2024
968b08b
refactor: refactor Suggested improvements from code review
ichanguk Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,56 @@
# android-contacts

- 카카오 테크 캠퍼스 과제(연락처 앱) 수행을 위한 저장소입니다.

## *Contents*
1. 홈 화면      2. 연락처 추가 화면     3. 취소 / 뒤로가기 팝업

<img src=https://github.com/ichanguk/android-contacts/blob/ichanguk/img/registerActivity.png width="200" height="350"><img src=https://github.com/ichanguk/android-contacts/blob/ichanguk/img/mainActivity.png width="200" height="350"><img src=https://github.com/ichanguk/android-contacts/blob/ichanguk/img/cancelEvent.png width="200" height="350">

4. 연락처 목록 화면      5. 연락처 목록 화면(회전)

<img src=https://github.com/ichanguk/android-contacts/blob/ichanguk/img/contactList.png width="200" height="350"><img src=https://github.com/ichanguk/android-contacts/blob/ichanguk/img/listRotation.png width="500" height="200">

6. 상세화면1     7. 상세 화면2

<img src=https://github.com/ichanguk/android-contacts/blob/ichanguk/img/detailActivity.png width="200" height="350"><img src=https://github.com/ichanguk/android-contacts/blob/ichanguk/img/detailActivity2.png width="200" height="350">

## feature

### 1단계 - 연락처 추가

1. 이름과 전화번호 입력 기능
- 이름과 전화번호는 필수 값으로 입력하지 않은 경우 토스트 메시지 보여준다.

2. 전화번호 입력 기능
- 숫자만 입력 가능

3. 더보기 기능
- 더보기를 눌러 입력 폼을 확장할 수 있다.
- 추가되는 입력 폼 : 생일, 성별, 메모

4. 성별 입력 기능
- 성별을 둘 중 하나를 선택할 수 있다.

5. 저장 기능
- 저장 버튼을 누르면 '저장이 완료 되었습니다' 라는 토스트 메시지를 보여준다.

6. 취소 기능
- 취소 버튼을 누르면 '취소 되었습니다' 라는 토스트 메시지를 보여준다.

7. 생일 입력 기능
- 생일을 달력에서 선택해서 입력할 수 있다.


### 2단계 - 연락처 목록

1. 연락처 등록 화면
- 연락처 추가 버튼을 누르면 연락처 추가 화면으로 넘어감

2. 연락처를 저장하면 목록에 추가
- 앱을 다시 실행하면 목록은 비어있음
- 저장된 연락처가 많을 경우 목록 스크롤 가능

3. 연락처 목록의 연락처를 선택하면 상세 화면 출력

4. 연락처 작성 중 뒤로가기 / 취소 버튼을 누르면 확인 팝업 출력
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-parcelize")
id("org.jlleitschuh.gradle.ktlint")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호... ktlint 설정까지 해주실 예정인걸까요?

}

android {
Expand Down Expand Up @@ -41,6 +43,7 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.activity:activity:1.8.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@
android:theme="@style/Theme.Contacts"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".DetailActivity"
android:exported="false" />
<activity
android:name=".RegisterActivity"
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=".MainActivity"
android:exported="true" />
</application>

</manifest>
</manifest>
14 changes: 14 additions & 0 deletions app/src/main/java/campus/tech/kakao/contacts/Contact.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package campus.tech.kakao.contacts

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class Contact(
val name: String,
val phoneNum: String,
val email: String,
val birthday: String,
val gender: Int,
val memo: String,
) : Parcelable
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parcelize 아주 좋습니다! 👍

107 changes: 107 additions & 0 deletions app/src/main/java/campus/tech/kakao/contacts/DetailActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package campus.tech.kakao.contacts

import android.os.Build
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout

class DetailActivity : AppCompatActivity() {
lateinit var detailNameTextView: TextView
lateinit var detailPhoneNumTextView: TextView
lateinit var detailEmailTextView: TextView
lateinit var detailBirthdayTextView: TextView
lateinit var detailGenderTextView: TextView
lateinit var detailMemoTextView: TextView
lateinit var detailEmailLayout: ConstraintLayout
lateinit var detailBirthdayLayout: ConstraintLayout
lateinit var detailGenderLayout: ConstraintLayout
lateinit var detailMemoLayout: ConstraintLayout
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

접근제한자를 습관적으로 선언하시는 것을 추천드립니다 :)


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_detail)

initViews()
setContactDetails()
}

/**
* 사용할 view들을 초기화하는 함수
*
* - `detailNameTextView` : 이름을 나타내는 TextView
* - `detailPhoneNumTextView` : 전화번호를 나타내는 TextView
* - `detailEmailTextView` : 메일을 나타내는 TextView
* - `detailBirthdayTextView` : 생일을 나타내는 TextView
* - `detailGenderTextView` : 성별을 나타내는 TextView
* - `detailMemoTextView` : 메모를 나타내는 TextView
* - `detailEmailLayout` : 메일 ConstraintLayout
* - `detailBirthdayLayout` : 생일 ConstraintLayout
* - `detailGenderLayout` : 성별 ConstraintLayout
* - `detailMemoLayout` : 메모 ConstraintLayout
*/
private fun initViews() {
detailNameTextView = findViewById(R.id.detail_name_text_view)
detailPhoneNumTextView = findViewById(R.id.detail_phone_num_text_view)
detailEmailTextView = findViewById(R.id.detail_email_text_view)
detailBirthdayTextView = findViewById(R.id.detail_birthday_text_view)
detailGenderTextView = findViewById(R.id.detail_gender_text_view)
detailMemoTextView = findViewById(R.id.detail_memo_text_view)

detailEmailLayout = findViewById(R.id.detail_email_layout)
detailBirthdayLayout = findViewById(R.id.detail_birthday_layout)
detailGenderLayout = findViewById(R.id.detail_gender_layout)
detailMemoLayout = findViewById(R.id.detail_memo_layout)
}
Comment on lines +44 to +56
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기본적으로 주석과 함수가 적절히 쪼개져 있는 것이 매우 보기 좋습니다.
다만 요러한 initViews 작업은 ViewBinding 을 사용한다면 코드 작성이 따로 필요 없이 간편하게 처리될 수 있을 것 같아요!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클론코딩 강사님께서 일단 findViewById를 사용하라고 하셔서 사용중인데 ViewBinding도 사용해보겠습니다!


/**
* 전달된 contact 정보를 view와 layout에 설정하는 함수.
*/
private fun setContactDetails() {
val contact: Contact? =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableExtra("contact", Contact::class.java)
} else {
intent.getParcelableExtra("contact")
}
Comment on lines +62 to +67
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullable, 버전 처리 매우 좋습니다!


contact?.let {
setDetailTextViews(it)
setDetailLayoutVisibility(it)
}
}

/**
* contact 정보로 TextView의 text를 설정하는 함수.
*
* @param contact RegisterActivity로 부터 받은 Contact 객체.
*/
private fun setDetailTextViews(contact: Contact) {
detailNameTextView.text = contact.name
detailPhoneNumTextView.text = contact.phoneNum
detailEmailTextView.text = contact.email ?: ""
detailBirthdayTextView.text = contact.birthday ?: ""
detailGenderTextView.text =
when (contact.gender) {
1 -> "여성"
2 -> "남성"
else -> ""
}
detailMemoTextView.text = contact.memo ?: ""
}

/**
* contact 정보로 layout의 visibility를 설정하는 함수.
*
* 빈 정보는 보이지 않도록 설정.
*
* @param contact RegisterActivity로 부터 받은 Contact 객체.
*/
private fun setDetailLayoutVisibility(contact: Contact) {
detailEmailLayout.visibility = if (contact.email.isEmpty()) View.GONE else View.VISIBLE
detailBirthdayLayout.visibility = if (contact.birthday.isEmpty()) View.GONE else View.VISIBLE
detailGenderLayout.visibility = if (contact.gender == 0) View.GONE else View.VISIBLE
detailMemoLayout.visibility = if (contact.memo.isEmpty()) View.GONE else View.VISIBLE
ichanguk marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading