From b4164c683b37ffecf5f525ce75e159262e6cfc96 Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 15:34:27 +0900 Subject: [PATCH 01/29] docs : update readme --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index cc0acc5a..1332116c 100644 --- a/README.md +++ b/README.md @@ -1 +1,21 @@ # android-contacts + +## 연락처 추가 + +- 연락처를 추가한다. +- 이름과 전화번호는 필수 값이다. + - 입력하지 않고 저장버튼 누르면 토스트 메시지 -> 포커스도 해당 부분으로 이동 +- 전화번호 입력은 숫자만 가능하다. +- 더보기를 눌러 입력 폼을 확장할 수 있다. + - 생일, 성별, 메모 입력 폼이 등장한다. + - 성별을 둘 중 하나를 선택할 수 있다. +- 저장 버튼을 누르면 '저장이 완료 되었습니다' 라는 토스트 메시지를 보여준다. +- 취소 버튼을 누르면 '취소 되었습니다' 라는 토스트 메시지를 보여준다. +- +## 구현할 기능 +- 이름을 입력하지 않고 저장버튼 누르면 '이름은 필수값입니다' 토스트 메시지, 포커스도 이름으로 +- 전화번호를 입력하지 않고 저장버튼 누르면 '전화번호는 필수값입니다' 토스트 메시지, 포커스도 전화번호로 +- 더보기를 눌러 입력 폼을 확장 +- 성별을 선택 +- 저장 버튼을 누르면 '저장이 완료 되었습니다' 토스트 메시지 +- 취소 버튼을 누르면 '취소 되었습니다' 토스트 메시지 \ No newline at end of file From 912bb20e4e9d5b1ef5f896ed9396d40139952d46 Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 15:46:01 +0900 Subject: [PATCH 02/29] design : ui setting --- app/src/main/res/layout/activity_main.xml | 187 ++++++++++++++++++++-- app/src/main/res/values/colors.xml | 2 + 2 files changed, 179 insertions(+), 10 deletions(-) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 24d17df2..69714b2f 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,19 +1,186 @@ - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 768b058a..c455f9f8 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,4 +2,6 @@ #FF000000 #FFFFFFFF + #8091F1E3 + #D38F8F8F From 903ff8b35d2fcf35f3f640e579c4569ba5e8c63a Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 20:49:30 +0900 Subject: [PATCH 03/29] feat : toast & focus when empty name --- .../tech/kakao/contacts/MainActivity.kt | 21 +++++++++++++++++++ app/src/main/res/layout/activity_main.xml | 8 +++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt index 7aae79fe..4fa5d47d 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt @@ -1,11 +1,32 @@ package campus.tech.kakao.contacts +import android.content.Context import android.os.Bundle +import android.view.inputmethod.InputMethodManager +import android.widget.EditText +import android.widget.TextView +import android.widget.Toast import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.widget.LinearLayoutCompat + class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + + + val name = findViewById(R.id.name) + val save = findViewById(R.id.save) + + save.setOnClickListener{ + if(name.text.isEmpty()) { + val toast = Toast.makeText(this, "이름은 필수값입니다", Toast.LENGTH_SHORT) + toast.show() + name.requestFocus() + val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + inputMethodManager.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT) + } + } } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 69714b2f..266d89ee 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -14,7 +14,7 @@ android:layout_height="100dp" android:layout_marginTop="20dp" android:layout_marginBottom="20dp" - android:src="@mipmap/ic_launcher_round"/> + android:src="@mipmap/ic_launcher_round" /> Date: Tue, 25 Jun 2024 20:55:30 +0900 Subject: [PATCH 04/29] feat : toast & focus when empty phone --- .../main/java/campus/tech/kakao/contacts/MainActivity.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt index 4fa5d47d..c7ff4787 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt @@ -17,14 +17,21 @@ class MainActivity : AppCompatActivity() { val name = findViewById(R.id.name) + val phone = findViewById(R.id.phone) val save = findViewById(R.id.save) + val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + save.setOnClickListener{ if(name.text.isEmpty()) { val toast = Toast.makeText(this, "이름은 필수값입니다", Toast.LENGTH_SHORT) toast.show() name.requestFocus() - val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + inputMethodManager.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT) + } else if(phone.text.isEmpty()) { + val toast = Toast.makeText(this, "전화번호는 필수값입니다", Toast.LENGTH_SHORT) + toast.show() + name.requestFocus() inputMethodManager.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT) } } From 9e9ca6bc8c1429822cd7d49e2b1c0d211ef07031 Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 21:00:08 +0900 Subject: [PATCH 05/29] fix : focus phone when empty phone --- app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt index c7ff4787..10c6b212 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt @@ -31,8 +31,8 @@ class MainActivity : AppCompatActivity() { } else if(phone.text.isEmpty()) { val toast = Toast.makeText(this, "전화번호는 필수값입니다", Toast.LENGTH_SHORT) toast.show() - name.requestFocus() - inputMethodManager.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT) + phone.requestFocus() + inputMethodManager.showSoftInput(phone, InputMethodManager.SHOW_IMPLICIT) } } } From 90f69ffcaa566c68c3abba37f0043c89d34a0fbe Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 21:08:26 +0900 Subject: [PATCH 06/29] feat : toast when saveBtn click --- app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt index 10c6b212..a5e9b971 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt @@ -33,6 +33,9 @@ class MainActivity : AppCompatActivity() { toast.show() phone.requestFocus() inputMethodManager.showSoftInput(phone, InputMethodManager.SHOW_IMPLICIT) + } else { + val toast = Toast.makeText(this, "저장이 완료 되었습니다", Toast.LENGTH_SHORT) + toast.show() } } } From c8a8b08680c12721647c8b85d923db6b45305598 Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 21:10:09 +0900 Subject: [PATCH 07/29] fix : adjust UI when keyboard mode --- app/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 89dc9d8b..566753cd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,6 +14,7 @@ tools:targetApi="31"> From f04c523a48af19a01eb025b396ee1474869dd4ab Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 21:14:04 +0900 Subject: [PATCH 08/29] feat : toast when cancelBtn click --- .../main/java/campus/tech/kakao/contacts/MainActivity.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt index a5e9b971..e5d08b08 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt @@ -19,6 +19,7 @@ class MainActivity : AppCompatActivity() { val name = findViewById(R.id.name) val phone = findViewById(R.id.phone) val save = findViewById(R.id.save) + val cancel = findViewById(R.id.cancel) val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager @@ -38,5 +39,12 @@ class MainActivity : AppCompatActivity() { toast.show() } } + + cancel.setOnClickListener{ + val toast = Toast.makeText(this, "취소 되었습니다", Toast.LENGTH_SHORT) + toast.show() + } + + } } From 69a63698ce276db2de9db2e61ea55c38785c4ceb Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 21:15:08 +0900 Subject: [PATCH 09/29] docs : update readme --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1332116c..f0baa47a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ ## 구현할 기능 - 이름을 입력하지 않고 저장버튼 누르면 '이름은 필수값입니다' 토스트 메시지, 포커스도 이름으로 - 전화번호를 입력하지 않고 저장버튼 누르면 '전화번호는 필수값입니다' 토스트 메시지, 포커스도 전화번호로 -- 더보기를 눌러 입력 폼을 확장 -- 성별을 선택 - 저장 버튼을 누르면 '저장이 완료 되었습니다' 토스트 메시지 -- 취소 버튼을 누르면 '취소 되었습니다' 토스트 메시지 \ No newline at end of file +- 취소 버튼을 누르면 '취소 되었습니다' 토스트 메시지 +- 더보기를 눌러 입력 폼을 확장 \ No newline at end of file From 6b06a1adfea4f242f3ff8392bb9d2fd2f162e302 Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 23:22:09 +0900 Subject: [PATCH 10/29] feat : moreBtn, scrollView --- .../tech/kakao/contacts/MainActivity.kt | 9 +- app/src/main/res/layout/activity_main.xml | 247 +++++++++--------- 2 files changed, 135 insertions(+), 121 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt index e5d08b08..20684325 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt @@ -2,12 +2,14 @@ package campus.tech.kakao.contacts import android.content.Context import android.os.Bundle +import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.EditText import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.LinearLayoutCompat +import androidx.core.view.isInvisible class MainActivity : AppCompatActivity() { @@ -18,6 +20,8 @@ class MainActivity : AppCompatActivity() { val name = findViewById(R.id.name) val phone = findViewById(R.id.phone) + val moreBtn = findViewById(R.id.moreBtn) + val moreInfo = findViewById(R.id.moreInfo) val save = findViewById(R.id.save) val cancel = findViewById(R.id.cancel) @@ -45,6 +49,9 @@ class MainActivity : AppCompatActivity() { toast.show() } - + moreBtn.setOnClickListener{ + moreInfo.visibility = View.VISIBLE + moreBtn.visibility = View.INVISIBLE + } } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 266d89ee..3556d88c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -5,156 +5,163 @@ android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" - android:gravity="center_horizontal" android:orientation="vertical" tools:context=".MainActivity"> - - - + android:layout_weight="1"> - - - - - - - + android:layout_height="0dp" + android:layout_weight="1" + android:gravity="center_horizontal" + android:orientation="vertical"> - + android:layout_height="100dp" + android:layout_marginTop="20dp" + android:layout_marginBottom="20dp" + android:src="@mipmap/ic_launcher_round" /> - - + + + + + + + android:layout_height="wrap_content"> - + android:layout_gravity="center_horizontal" + android:gravity="center" + android:text="더보기" + android:textColor="@color/black" + android:textSize="20dp" /> + - - + + - + - - - + + - + android:orientation="horizontal"> + + + + + + + + + - - - + - + - + Date: Tue, 25 Jun 2024 23:23:45 +0900 Subject: [PATCH 11/29] docs : update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f0baa47a..1651618c 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,5 @@ - 전화번호를 입력하지 않고 저장버튼 누르면 '전화번호는 필수값입니다' 토스트 메시지, 포커스도 전화번호로 - 저장 버튼을 누르면 '저장이 완료 되었습니다' 토스트 메시지 - 취소 버튼을 누르면 '취소 되었습니다' 토스트 메시지 -- 더보기를 눌러 입력 폼을 확장 \ No newline at end of file +- 더보기를 눌러 입력 폼을 확장 +- 생일 선택 후 텍스트 반영 \ No newline at end of file From 4a86524ad023706169908327bf3762c202f46738 Mon Sep 17 00:00:00 2001 From: anyooin Date: Tue, 25 Jun 2024 23:54:38 +0900 Subject: [PATCH 12/29] feat : select birthday with datepicker --- .../tech/kakao/contacts/MainActivity.kt | 30 +++++++++++++++---- app/src/main/res/layout/activity_main.xml | 7 ++--- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt index 20684325..ebfb8730 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt @@ -1,5 +1,6 @@ package campus.tech.kakao.contacts +import android.app.DatePickerDialog import android.content.Context import android.os.Bundle import android.view.View @@ -10,6 +11,7 @@ import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.LinearLayoutCompat import androidx.core.view.isInvisible +import java.util.Calendar class MainActivity : AppCompatActivity() { @@ -22,18 +24,20 @@ class MainActivity : AppCompatActivity() { val phone = findViewById(R.id.phone) val moreBtn = findViewById(R.id.moreBtn) val moreInfo = findViewById(R.id.moreInfo) + val birthday = findViewById(R.id.birthday) val save = findViewById(R.id.save) val cancel = findViewById(R.id.cancel) - val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + val inputMethodManager = + getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - save.setOnClickListener{ - if(name.text.isEmpty()) { + save.setOnClickListener { + if (name.text.isEmpty()) { val toast = Toast.makeText(this, "이름은 필수값입니다", Toast.LENGTH_SHORT) toast.show() name.requestFocus() inputMethodManager.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT) - } else if(phone.text.isEmpty()) { + } else if (phone.text.isEmpty()) { val toast = Toast.makeText(this, "전화번호는 필수값입니다", Toast.LENGTH_SHORT) toast.show() phone.requestFocus() @@ -44,14 +48,28 @@ class MainActivity : AppCompatActivity() { } } - cancel.setOnClickListener{ + cancel.setOnClickListener { val toast = Toast.makeText(this, "취소 되었습니다", Toast.LENGTH_SHORT) toast.show() } - moreBtn.setOnClickListener{ + moreBtn.setOnClickListener { moreInfo.visibility = View.VISIBLE moreBtn.visibility = View.INVISIBLE } + + birthday.setOnClickListener { + val calendar = Calendar.getInstance() //캘린더뷰 만들기 + val dateSetListener = + DatePickerDialog.OnDateSetListener { view, year, month, dayOfMonth -> + birthday.text = "" + year + "." + (month + 1) + "." + dayOfMonth + } + DatePickerDialog( + this, dateSetListener, + calendar.get(Calendar.YEAR), + calendar.get(Calendar.MONTH), + calendar.get(Calendar.DAY_OF_MONTH) + ).show() + } } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3556d88c..c2c43934 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -86,7 +86,7 @@ android:orientation="vertical" android:visibility="invisible"> - @@ -114,8 +114,7 @@ android:layout_weight="1.3" android:gravity="center_vertical" android:paddingLeft="15dp" - android:text="성별" - android:textColor="@color/gray" + android:hint="성별" android:textSize="15dp" /> Date: Wed, 26 Jun 2024 15:18:41 +0900 Subject: [PATCH 13/29] design : change icons --- .../tech/kakao/contacts/MainActivity.kt | 4 +- .../baseline_keyboard_arrow_down_24.xml | 5 ++ app/src/main/res/drawable/image_default.xml | 5 ++ app/src/main/res/drawable/text_background.xml | 15 ++++++ app/src/main/res/layout/activity_main.xml | 49 +++++++++++-------- app/src/main/res/values/colors.xml | 2 +- 6 files changed, 57 insertions(+), 23 deletions(-) create mode 100644 app/src/main/res/drawable/baseline_keyboard_arrow_down_24.xml create mode 100644 app/src/main/res/drawable/image_default.xml create mode 100644 app/src/main/res/drawable/text_background.xml diff --git a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt index ebfb8730..f8fe4ce8 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt @@ -22,7 +22,7 @@ class MainActivity : AppCompatActivity() { val name = findViewById(R.id.name) val phone = findViewById(R.id.phone) - val moreBtn = findViewById(R.id.moreBtn) + val moreBtn = findViewById(R.id.moreBtn) val moreInfo = findViewById(R.id.moreInfo) val birthday = findViewById(R.id.birthday) val save = findViewById(R.id.save) @@ -31,6 +31,8 @@ class MainActivity : AppCompatActivity() { val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + moreInfo.visibility = View.INVISIBLE + save.setOnClickListener { if (name.text.isEmpty()) { val toast = Toast.makeText(this, "이름은 필수값입니다", Toast.LENGTH_SHORT) diff --git a/app/src/main/res/drawable/baseline_keyboard_arrow_down_24.xml b/app/src/main/res/drawable/baseline_keyboard_arrow_down_24.xml new file mode 100644 index 00000000..1a69b23f --- /dev/null +++ b/app/src/main/res/drawable/baseline_keyboard_arrow_down_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/image_default.xml b/app/src/main/res/drawable/image_default.xml new file mode 100644 index 00000000..665f371f --- /dev/null +++ b/app/src/main/res/drawable/image_default.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/text_background.xml b/app/src/main/res/drawable/text_background.xml new file mode 100644 index 00000000..c5e8f5cc --- /dev/null +++ b/app/src/main/res/drawable/text_background.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index c2c43934..45c43a6d 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -21,11 +21,11 @@ android:orientation="vertical"> + android:src="@drawable/image_default" /> @@ -46,7 +46,7 @@ android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_marginBottom="15dp" - android:background="@color/lightBlue" + android:background="@drawable/text_background" android:hint="전화번호" android:inputType="number" android:paddingLeft="15dp" @@ -59,7 +59,7 @@ android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_marginBottom="15dp" - android:background="@color/lightBlue" + android:background="@drawable/text_background" android:hint="메일" android:paddingLeft="15dp" android:textSize="15dp" /> @@ -68,23 +68,35 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:orientation="horizontal"> + + + + + + + android:orientation="vertical" > @@ -164,8 +176,7 @@ @@ -173,8 +184,6 @@ android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_marginLeft="30dp" - android:layout_marginRight="30dp" android:layout_weight="1" android:gravity="center" android:text="취소" @@ -184,8 +193,6 @@ android:id="@+id/save" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_marginLeft="30dp" - android:layout_marginRight="30dp" android:layout_weight="1" android:gravity="center" android:text="저장" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c455f9f8..63bde316 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,6 +2,6 @@ #FF000000 #FFFFFFFF - #8091F1E3 + #77B2EFF4 #D38F8F8F From 79caaae5754b5ce971b11fb2475033a77ca8e3ed Mon Sep 17 00:00:00 2001 From: anyooin Date: Thu, 27 Jun 2024 14:32:41 +0900 Subject: [PATCH 14/29] design : contactmain UI --- app/src/main/AndroidManifest.xml | 9 ++-- .../kakao/contacts/ContactMainActivity.kt | 20 +++++++++ app/src/main/res/drawable/baseline_add_24.xml | 5 +++ .../main/res/drawable/profile_background.xml | 10 +++++ .../main/res/layout/activity_contact_main.xml | 33 +++++++++++++++ app/src/main/res/layout/activity_main.xml | 41 +++++++++++-------- app/src/main/res/layout/item_contact.xml | 31 ++++++++++++++ app/src/main/res/values/colors.xml | 2 + 8 files changed, 130 insertions(+), 21 deletions(-) create mode 100644 app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt create mode 100644 app/src/main/res/drawable/baseline_add_24.xml create mode 100644 app/src/main/res/drawable/profile_background.xml create mode 100644 app/src/main/res/layout/activity_contact_main.xml create mode 100644 app/src/main/res/layout/item_contact.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 566753cd..dac66c07 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,10 +12,13 @@ android:supportsRtl="true" android:theme="@style/Theme.Contacts" tools:targetApi="31"> + + android:exported="true" + android:windowSoftInputMode="adjustResize"> @@ -24,4 +27,4 @@ - + \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt new file mode 100644 index 00000000..c886e757 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt @@ -0,0 +1,20 @@ +package campus.tech.kakao.contacts + +import android.os.Bundle +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat + +class ContactMainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContentView(R.layout.activity_contact_main) + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> + val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) + insets + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/baseline_add_24.xml b/app/src/main/res/drawable/baseline_add_24.xml new file mode 100644 index 00000000..9f83b8fb --- /dev/null +++ b/app/src/main/res/drawable/baseline_add_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/profile_background.xml b/app/src/main/res/drawable/profile_background.xml new file mode 100644 index 00000000..194d9e28 --- /dev/null +++ b/app/src/main/res/drawable/profile_background.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_contact_main.xml b/app/src/main/res/layout/activity_contact_main.xml new file mode 100644 index 00000000..745cc8cf --- /dev/null +++ b/app/src/main/res/layout/activity_contact_main.xml @@ -0,0 +1,33 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 45c43a6d..2aeb7848 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -15,8 +15,7 @@ @@ -36,8 +35,9 @@ android:layout_marginBottom="15dp" android:background="@drawable/text_background" android:hint="이름" - android:paddingLeft="15dp" - android:textSize="15dp" /> + android:paddingStart="15dp" + android:paddingEnd="15dp" + android:textSize="15sp" /> + android:inputType="phone" + android:paddingStart="15dp" + android:paddingEnd="15dp" + android:textSize="15sp" /> + android:paddingStart="15dp" + android:paddingEnd="15dp" + android:textSize="15sp" /> + android:textSize="20sp" /> + android:paddingStart="15dp" + android:paddingEnd="15dp" + android:textSize="15sp" /> + android:textSize="15sp" /> + android:paddingStart="15dp" + android:paddingEnd="15dp" + android:textSize="15sp" /> @@ -187,7 +192,7 @@ android:layout_weight="1" android:gravity="center" android:text="취소" - android:textSize="25dp" /> + android:textSize="25sp" /> + android:textSize="25sp" /> diff --git a/app/src/main/res/layout/item_contact.xml b/app/src/main/res/layout/item_contact.xml new file mode 100644 index 00000000..6c7424b4 --- /dev/null +++ b/app/src/main/res/layout/item_contact.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 63bde316..7b115d97 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -4,4 +4,6 @@ #FFFFFFFF #77B2EFF4 #D38F8F8F + #FFFFC800 + #FFFF6F00 From 865dec97dd6469ed2a68f53bc8f0892d3d7bd6c4 Mon Sep 17 00:00:00 2001 From: anyooin Date: Thu, 27 Jun 2024 14:36:27 +0900 Subject: [PATCH 15/29] docs : update readme --- README.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1651618c..ef40ad6f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # android-contacts -## 연락처 추가 - +## 1단계 : 연락처 추가 - 연락처를 추가한다. - 이름과 전화번호는 필수 값이다. - 입력하지 않고 저장버튼 누르면 토스트 메시지 -> 포커스도 해당 부분으로 이동 @@ -12,10 +11,24 @@ - 저장 버튼을 누르면 '저장이 완료 되었습니다' 라는 토스트 메시지를 보여준다. - 취소 버튼을 누르면 '취소 되었습니다' 라는 토스트 메시지를 보여준다. - -## 구현할 기능 +### 구현할 기능 - 이름을 입력하지 않고 저장버튼 누르면 '이름은 필수값입니다' 토스트 메시지, 포커스도 이름으로 - 전화번호를 입력하지 않고 저장버튼 누르면 '전화번호는 필수값입니다' 토스트 메시지, 포커스도 전화번호로 - 저장 버튼을 누르면 '저장이 완료 되었습니다' 토스트 메시지 - 취소 버튼을 누르면 '취소 되었습니다' 토스트 메시지 - 더보기를 눌러 입력 폼을 확장 -- 생일 선택 후 텍스트 반영 \ No newline at end of file +- 생일 선택 후 텍스트 반영 + +## 2단계 : 연락처 목록 +- 연락처 등록 화면을 구현한다. +- 연락처를 저장하면 목록에 추가된다. +- 저장된 연락처가 많을 경우 목록은 스크롤 되어야 한다. +- 추가된 연락처를 선택하여 상세 화면을 볼 수 있다. +- 연락처 작성 중 뒤로가기 버튼을 누르면 확인 팝업이 나타난다. +- 추가된 연락처는 앱을 다시 실행하면 유지되지 않는다. + +### 구현할 기능 +- +버튼을 누르면 연락처 등록 화면으로 이동 +- 연락처 저장 버튼을 누르면 목록에 추가 +- 연락처 작성 중 뒤로가기 버튼 누르면 확인 팝업 +- 추가된 연락처목록을 선택하면 상세화면으로 이동 \ No newline at end of file From 9bfc39701a40664c2d21f1cea892863c50f399a1 Mon Sep 17 00:00:00 2001 From: anyooin Date: Thu, 27 Jun 2024 14:51:08 +0900 Subject: [PATCH 16/29] feat : floatingbutton click event to writingactivity --- app/src/main/AndroidManifest.xml | 4 ++-- .../tech/kakao/contacts/ContactMainActivity.kt | 13 ++++++++----- .../{MainActivity.kt => ContactWritingActivity.kt} | 5 ++--- app/src/main/res/layout/activity_contact_main.xml | 1 + ...tivity_main.xml => activity_contact_writing.xml} | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) rename app/src/main/java/campus/tech/kakao/contacts/{MainActivity.kt => ContactWritingActivity.kt} (95%) rename app/src/main/res/layout/{activity_main.xml => activity_contact_writing.xml} (99%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dac66c07..ba5f40f1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,10 +13,10 @@ android:theme="@style/Theme.Contacts" tools:targetApi="31"> diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt index c886e757..af421f76 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt @@ -1,20 +1,23 @@ package campus.tech.kakao.contacts +import android.content.Intent import android.os.Bundle import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat +import com.google.android.material.floatingactionbutton.FloatingActionButton class ContactMainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - enableEdgeToEdge() setContentView(R.layout.activity_contact_main) - ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> - val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) - v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) - insets + + val floatingBtn = findViewById(R.id.floatingBtn) + + floatingBtn.setOnClickListener{ + val intent = Intent(this, ContactWritingActivity::class.java) + startActivity(intent) } } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt similarity index 95% rename from app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt rename to app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt index f8fe4ce8..0734815d 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/MainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt @@ -10,14 +10,13 @@ import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.LinearLayoutCompat -import androidx.core.view.isInvisible import java.util.Calendar -class MainActivity : AppCompatActivity() { +class ContactWritingActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + setContentView(R.layout.activity_contact_writing) val name = findViewById(R.id.name) diff --git a/app/src/main/res/layout/activity_contact_main.xml b/app/src/main/res/layout/activity_contact_main.xml index 745cc8cf..b258b0e0 100644 --- a/app/src/main/res/layout/activity_contact_main.xml +++ b/app/src/main/res/layout/activity_contact_main.xml @@ -21,6 +21,7 @@ android:layout_centerInParent="true"/> + tools:context=".ContactWritingActivity"> Date: Thu, 27 Jun 2024 14:55:07 +0900 Subject: [PATCH 17/29] docs : update readme --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ef40ad6f..efd4563f 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,9 @@ - 추가된 연락처는 앱을 다시 실행하면 유지되지 않는다. ### 구현할 기능 -- +버튼을 누르면 연락처 등록 화면으로 이동 -- 연락처 저장 버튼을 누르면 목록에 추가 -- 연락처 작성 중 뒤로가기 버튼 누르면 확인 팝업 -- 추가된 연락처목록을 선택하면 상세화면으로 이동 \ No newline at end of file +- 메인화면에서 +버튼을 누르면 연락처 등록 화면으로 이동 +- 작성한 정보를 메인화면으로 넘겨주기 +- 연락처 저장 버튼을 누르면 메인화면으로 이동 +- 작성한 연락처를 메인 목록에 추가 +- 연락처 작성 중(작성내용이 있으면) 뒤로가기 버튼 누르면 확인 팝업 +- 추가된 연락처 목록을 선택하면 상세화면으로 이동 \ No newline at end of file From 7eb8f84e73c82f9c3ee000fb2c58ab6327115745 Mon Sep 17 00:00:00 2001 From: anyooin Date: Thu, 27 Jun 2024 15:38:26 +0900 Subject: [PATCH 18/29] feat : data transfer from writing to main --- .../tech/kakao/contacts/ContactMainActivity.kt | 6 ++++++ .../kakao/contacts/ContactWritingActivity.kt | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt index af421f76..2348bc9c 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt @@ -2,6 +2,7 @@ package campus.tech.kakao.contacts import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import androidx.core.view.ViewCompat @@ -14,10 +15,15 @@ class ContactMainActivity : AppCompatActivity() { setContentView(R.layout.activity_contact_main) val floatingBtn = findViewById(R.id.floatingBtn) + val name = intent.getStringExtra("name") + val phone = intent.getStringExtra("phone") floatingBtn.setOnClickListener{ val intent = Intent(this, ContactWritingActivity::class.java) startActivity(intent) } + + Log.d("uin", "main " + name + " " + phone) + } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt index 0734815d..78a604bc 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt @@ -2,10 +2,13 @@ package campus.tech.kakao.contacts import android.app.DatePickerDialog import android.content.Context +import android.content.Intent import android.os.Bundle +import android.util.Log import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.EditText +import android.widget.RadioGroup import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity @@ -21,9 +24,12 @@ class ContactWritingActivity : AppCompatActivity() { val name = findViewById(R.id.name) val phone = findViewById(R.id.phone) + val mail = findViewById(R.id.mail) val moreBtn = findViewById(R.id.moreBtn) val moreInfo = findViewById(R.id.moreInfo) val birthday = findViewById(R.id.birthday) + val gender = findViewById(R.id.gender) + val memo = findViewById(R.id.memo) val save = findViewById(R.id.save) val cancel = findViewById(R.id.cancel) @@ -46,6 +52,16 @@ class ContactWritingActivity : AppCompatActivity() { } else { val toast = Toast.makeText(this, "저장이 완료 되었습니다", Toast.LENGTH_SHORT) toast.show() + + val intent = Intent(this, ContactMainActivity::class.java) + intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) + intent.putExtra("name", name.text.toString()) + intent.putExtra("phone", phone.text.toString()) + //intent.putExtra("mail", mail.text) + //intent.putExtra("birthday", birthday.text) + //intent.putExtra("gender", name.text) //gender 선택한 값으로 + //intent.putExtra("memo", memo.text) + startActivity(intent) } } From 897b630b2d35f4685951ff1ced3ac9e940366473 Mon Sep 17 00:00:00 2001 From: anyooin Date: Thu, 27 Jun 2024 19:31:25 +0900 Subject: [PATCH 19/29] feat : make contact list --- app/src/main/AndroidManifest.xml | 6 +-- .../kakao/contacts/ContactMainActivity.kt | 52 ++++++++++++++++++- .../kakao/contacts/ContactWritingActivity.kt | 2 +- app/src/main/res/layout/item_contact.xml | 2 + 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ba5f40f1..1374fff5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,11 +14,11 @@ tools:targetApi="31"> + android:exported="false" + android:windowSoftInputMode="adjustResize"/> + android:exported="true"> diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt index 2348bc9c..eb8a486c 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt @@ -3,13 +3,22 @@ package campus.tech.kakao.contacts import android.content.Intent import android.os.Bundle import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import com.google.android.material.floatingactionbutton.FloatingActionButton +val contactList = mutableListOf() + class ContactMainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_contact_main) @@ -18,12 +27,51 @@ class ContactMainActivity : AppCompatActivity() { val name = intent.getStringExtra("name") val phone = intent.getStringExtra("phone") + if(name != null && phone != null) { + contactList.add(Contact(name, phone)) + } + floatingBtn.setOnClickListener{ val intent = Intent(this, ContactWritingActivity::class.java) + intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) startActivity(intent) } - Log.d("uin", "main " + name + " " + phone) + Log.d("uin", "main " + name + " " + phone + " " + contactList.size) + + val recyclerView = findViewById(R.id.recyclerView) + + recyclerView.adapter = RecyclerViewAdapter(contactList, LayoutInflater.from(this)) + recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) + + } +} + +class RecyclerViewAdapter( + val contactList : MutableList, val layoutInflater: LayoutInflater +): RecyclerView.Adapter() { + inner class ViewHolder(itemView : View): RecyclerView.ViewHolder(itemView) { + val name : TextView + val profile : TextView + init{ + name = itemView.findViewById(R.id.name) + profile = itemView.findViewById(R.id.profile) + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + val view = layoutInflater.inflate(R.layout.item_contact, parent, false) + return ViewHolder(view) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + holder.name.text = contactList.get(position).name + holder.profile.text = contactList.get(position).name.substring(0, 1) + } + override fun getItemCount(): Int { + return contactList.size } -} \ No newline at end of file +} + +class Contact(val name : String, val phone : String) \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt index 78a604bc..24d42ff8 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt @@ -54,7 +54,7 @@ class ContactWritingActivity : AppCompatActivity() { toast.show() val intent = Intent(this, ContactMainActivity::class.java) - intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) intent.putExtra("name", name.text.toString()) intent.putExtra("phone", phone.text.toString()) //intent.putExtra("mail", mail.text) diff --git a/app/src/main/res/layout/item_contact.xml b/app/src/main/res/layout/item_contact.xml index 6c7424b4..c08c3d48 100644 --- a/app/src/main/res/layout/item_contact.xml +++ b/app/src/main/res/layout/item_contact.xml @@ -10,6 +10,7 @@ android:gravity="center_vertical"> Date: Thu, 27 Jun 2024 19:52:36 +0900 Subject: [PATCH 20/29] design : add cardview corner radius, shadow --- app/src/main/res/layout/item_contact.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/item_contact.xml b/app/src/main/res/layout/item_contact.xml index c08c3d48..3c03c710 100644 --- a/app/src/main/res/layout/item_contact.xml +++ b/app/src/main/res/layout/item_contact.xml @@ -1,7 +1,13 @@ + android:layout_height="wrap_content" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_marginStart="25dp" + android:layout_marginEnd="25dp" + android:layout_marginTop="30dp" + app:cardCornerRadius="10dp" + app:cardElevation="10dp"> - \ No newline at end of file + From 3059465829a27e6d290dd0f19da4d31fb129bba0 Mon Sep 17 00:00:00 2001 From: anyooin Date: Thu, 27 Jun 2024 20:17:13 +0900 Subject: [PATCH 21/29] docs : update readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index efd4563f..84a3d800 100644 --- a/README.md +++ b/README.md @@ -32,5 +32,9 @@ - 작성한 정보를 메인화면으로 넘겨주기 - 연락처 저장 버튼을 누르면 메인화면으로 이동 - 작성한 연락처를 메인 목록에 추가 -- 연락처 작성 중(작성내용이 있으면) 뒤로가기 버튼 누르면 확인 팝업 +- 연락처 작성 중인 상태인지 체크(작성 내용이 하나라도 있으면 작성 중인 상태) +- 작성 중인 상태가 아니라면 뒤로가기 눌렀을때 연락처 목록 화면으로 +- 작성 중인 상태라면 뒤로가기 버튼 누르면 팝업 +- 팝업에서 작성하기 누르면 원래 작성하던 화면으로 +- 팝업에서 나가기 누르면 연락처 목록 화면으로 - 추가된 연락처 목록을 선택하면 상세화면으로 이동 \ No newline at end of file From 4cb1b67f100652cee2ce161771aca2db7a5786dd Mon Sep 17 00:00:00 2001 From: anyooin Date: Thu, 27 Jun 2024 20:41:51 +0900 Subject: [PATCH 22/29] feat : check writing state --- .../tech/kakao/contacts/ContactWritingActivity.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt index 24d42ff8..b3c19ef1 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt @@ -90,3 +90,15 @@ class ContactWritingActivity : AppCompatActivity() { } } } + +fun checkWriting(name : EditText, phone : EditText, mail : EditText, birthday : TextView, + gender : RadioGroup, memo : EditText) : Boolean { + if(name.text.isNotEmpty()|| phone.text.isNotEmpty() || mail.text.isNotEmpty() + || birthday.text.isNotEmpty() || memo.text.isNotEmpty()) { + return true + } + if(gender.checkedRadioButtonId != -1) { + return true + } + return false +} \ No newline at end of file From d7300948df8955bede5ec1195c7ccf1a7bbc152f Mon Sep 17 00:00:00 2001 From: anyooin Date: Fri, 28 Jun 2024 01:46:40 +0900 Subject: [PATCH 23/29] feat : back button popup --- .../kakao/contacts/ContactMainActivity.kt | 2 +- .../kakao/contacts/ContactWritingActivity.kt | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt index eb8a486c..51900d6a 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt @@ -33,7 +33,7 @@ class ContactMainActivity : AppCompatActivity() { floatingBtn.setOnClickListener{ val intent = Intent(this, ContactWritingActivity::class.java) - intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) + //intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) startActivity(intent) } diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt index b3c19ef1..187b6b8c 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt @@ -1,35 +1,39 @@ package campus.tech.kakao.contacts +import android.app.AlertDialog import android.app.DatePickerDialog import android.content.Context +import android.content.DialogInterface import android.content.Intent import android.os.Bundle import android.util.Log +import android.view.KeyEvent import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.EditText import android.widget.RadioGroup import android.widget.TextView import android.widget.Toast +import android.window.OnBackInvokedDispatcher import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.LinearLayoutCompat import java.util.Calendar class ContactWritingActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_contact_writing) - val name = findViewById(R.id.name) val phone = findViewById(R.id.phone) val mail = findViewById(R.id.mail) - val moreBtn = findViewById(R.id.moreBtn) - val moreInfo = findViewById(R.id.moreInfo) val birthday = findViewById(R.id.birthday) val gender = findViewById(R.id.gender) val memo = findViewById(R.id.memo) + val moreBtn = findViewById(R.id.moreBtn) + val moreInfo = findViewById(R.id.moreInfo) val save = findViewById(R.id.save) val cancel = findViewById(R.id.cancel) @@ -88,6 +92,20 @@ class ContactWritingActivity : AppCompatActivity() { calendar.get(Calendar.DAY_OF_MONTH) ).show() } + + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + if(keyCode == KeyEvent.KEYCODE_BACK) { + AlertDialog.Builder(this).run { + setMessage("작성 중인 내용이 있습니다. 정말 나가시겠습니까?") + setNegativeButton("나가기", null) + setPositiveButton("작성하기", null) + show() + } + return true; + } + return super.onKeyDown(keyCode, event) } } @@ -95,6 +113,7 @@ fun checkWriting(name : EditText, phone : EditText, mail : EditText, birthday : gender : RadioGroup, memo : EditText) : Boolean { if(name.text.isNotEmpty()|| phone.text.isNotEmpty() || mail.text.isNotEmpty() || birthday.text.isNotEmpty() || memo.text.isNotEmpty()) { + return true } if(gender.checkedRadioButtonId != -1) { From 8670bd71fa263a7e78059a0458809914f614f35f Mon Sep 17 00:00:00 2001 From: anyooin Date: Fri, 28 Jun 2024 01:49:10 +0900 Subject: [PATCH 24/29] docs : update readme --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 84a3d800..280b37cf 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,7 @@ - 작성한 정보를 메인화면으로 넘겨주기 - 연락처 저장 버튼을 누르면 메인화면으로 이동 - 작성한 연락처를 메인 목록에 추가 -- 연락처 작성 중인 상태인지 체크(작성 내용이 하나라도 있으면 작성 중인 상태) -- 작성 중인 상태가 아니라면 뒤로가기 눌렀을때 연락처 목록 화면으로 +- 연락처 작성 중인 상태인지 체크(작성 내용이 하나라도 있으면 작성 중인 상태) - 작성 중인 상태라면 뒤로가기 버튼 누르면 팝업 -- 팝업에서 작성하기 누르면 원래 작성하던 화면으로 - 팝업에서 나가기 누르면 연락처 목록 화면으로 - 추가된 연락처 목록을 선택하면 상세화면으로 이동 \ No newline at end of file From 730acd02514af0c16769a57329031b1a9d012416 Mon Sep 17 00:00:00 2001 From: anyooin Date: Fri, 28 Jun 2024 01:52:09 +0900 Subject: [PATCH 25/29] feat : press popup's exit button --- .../kakao/contacts/ContactWritingActivity.kt | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt index 187b6b8c..d9e3b327 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt @@ -97,14 +97,33 @@ class ContactWritingActivity : AppCompatActivity() { override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { if(keyCode == KeyEvent.KEYCODE_BACK) { + val name = findViewById(R.id.name) + val phone = findViewById(R.id.phone) + val mail = findViewById(R.id.mail) + val birthday = findViewById(R.id.birthday) + val gender = findViewById(R.id.gender) + val memo = findViewById(R.id.memo) + + if(checkWriting(name, phone, mail, birthday, gender, memo)) { + val dialogListener = DialogInterface.OnClickListener { dialog, which -> + if(which == DialogInterface.BUTTON_POSITIVE) { + Log.d("uin", "작성하기 버튼") + } else if(which == DialogInterface.BUTTON_NEGATIVE) { + Log.d("uin", "나가기 버튼") + val intent = Intent(this, ContactMainActivity::class.java) + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) + startActivity(intent) + } + } AlertDialog.Builder(this).run { setMessage("작성 중인 내용이 있습니다. 정말 나가시겠습니까?") - setNegativeButton("나가기", null) - setPositiveButton("작성하기", null) + setNegativeButton("나가기", dialogListener) + setPositiveButton("작성하기", dialogListener) show() } return true; } + } return super.onKeyDown(keyCode, event) } } From 4720922d5f0832d8d0a1fd394e3720657ad23707 Mon Sep 17 00:00:00 2001 From: anyooin Date: Fri, 28 Jun 2024 01:57:49 +0900 Subject: [PATCH 26/29] feat : invisible ContactMainActivity text when contact exist --- README.md | 1 + .../kakao/contacts/ContactMainActivity.kt | 32 +++++++++++-------- .../main/res/layout/activity_contact_main.xml | 1 + 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 280b37cf..dd3c5921 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,5 @@ - 연락처 작성 중인 상태인지 체크(작성 내용이 하나라도 있으면 작성 중인 상태) - 작성 중인 상태라면 뒤로가기 버튼 누르면 팝업 - 팝업에서 나가기 누르면 연락처 목록 화면으로 +- 목록에 연락처가 하나라도 있으면 메인화면의 텍스트 없애기 - 추가된 연락처 목록을 선택하면 상세화면으로 이동 \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt index 51900d6a..b9548799 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt @@ -23,37 +23,41 @@ class ContactMainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_contact_main) + val text = findViewById(R.id.text) val floatingBtn = findViewById(R.id.floatingBtn) + val recyclerView = findViewById(R.id.recyclerView) val name = intent.getStringExtra("name") val phone = intent.getStringExtra("phone") - if(name != null && phone != null) { + if (name != null && phone != null) { contactList.add(Contact(name, phone)) } - floatingBtn.setOnClickListener{ + if (contactList.size > 0) { + text.visibility = View.INVISIBLE + } else { + text.visibility = View.VISIBLE + } + + floatingBtn.setOnClickListener { val intent = Intent(this, ContactWritingActivity::class.java) //intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) startActivity(intent) } - Log.d("uin", "main " + name + " " + phone + " " + contactList.size) - - val recyclerView = findViewById(R.id.recyclerView) - recyclerView.adapter = RecyclerViewAdapter(contactList, LayoutInflater.from(this)) recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) - } } class RecyclerViewAdapter( - val contactList : MutableList, val layoutInflater: LayoutInflater -): RecyclerView.Adapter() { - inner class ViewHolder(itemView : View): RecyclerView.ViewHolder(itemView) { - val name : TextView - val profile : TextView - init{ + val contactList: MutableList, val layoutInflater: LayoutInflater +) : RecyclerView.Adapter() { + inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val name: TextView + val profile: TextView + + init { name = itemView.findViewById(R.id.name) profile = itemView.findViewById(R.id.profile) } @@ -74,4 +78,4 @@ class RecyclerViewAdapter( } } -class Contact(val name : String, val phone : String) \ No newline at end of file +class Contact(val name: String, val phone: String) \ No newline at end of file diff --git a/app/src/main/res/layout/activity_contact_main.xml b/app/src/main/res/layout/activity_contact_main.xml index b258b0e0..da4b4b65 100644 --- a/app/src/main/res/layout/activity_contact_main.xml +++ b/app/src/main/res/layout/activity_contact_main.xml @@ -14,6 +14,7 @@ android:layout_height="match_parent" /> Date: Fri, 28 Jun 2024 14:44:16 +0900 Subject: [PATCH 27/29] feat : contactDetailActivity --- app/src/main/AndroidManifest.xml | 5 +- .../kakao/contacts/ContactDetailActivity.kt | 29 +++ .../kakao/contacts/ContactMainActivity.kt | 37 +++- .../kakao/contacts/ContactWritingActivity.kt | 16 +- .../res/layout/activity_contact_detail.xml | 188 ++++++++++++++++++ 5 files changed, 267 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/campus/tech/kakao/contacts/ContactDetailActivity.kt create mode 100644 app/src/main/res/layout/activity_contact_detail.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1374fff5..dad13fe6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,10 +12,13 @@ android:supportsRtl="true" android:theme="@style/Theme.Contacts" tools:targetApi="31"> + + android:windowSoftInputMode="adjustResize" /> diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactDetailActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactDetailActivity.kt new file mode 100644 index 00000000..89c2fb6d --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactDetailActivity.kt @@ -0,0 +1,29 @@ +package campus.tech.kakao.contacts + +import android.os.Bundle +import android.widget.TextView +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat + +class ContactDetailActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_contact_detail) + + val nameTextView = findViewById(R.id.name) + val phoneTextView = findViewById(R.id.phone) + val mailTextView = findViewById(R.id.mail) + val birthdayTextView = findViewById(R.id.birthday) + val genderTextView = findViewById(R.id.gender) + val memoTextView = findViewById(R.id.memo) + + nameTextView.text = intent.getStringExtra("name") + phoneTextView.text = intent.getStringExtra("phone") + mailTextView.text = intent.getStringExtra("mail") + birthdayTextView.text = intent.getStringExtra("birthday") + genderTextView.text =intent.getStringExtra("gender") + memoTextView.text = intent.getStringExtra("memo") + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt index b9548799..6205031b 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt @@ -28,9 +28,13 @@ class ContactMainActivity : AppCompatActivity() { val recyclerView = findViewById(R.id.recyclerView) val name = intent.getStringExtra("name") val phone = intent.getStringExtra("phone") + val mail = intent.getStringExtra("mail") ?: "" + val birthday = intent.getStringExtra("birthday") ?: "" + val gender = intent.getStringExtra("gender") ?: "" + val memo = intent.getStringExtra("memo") ?: "" if (name != null && phone != null) { - contactList.add(Contact(name, phone)) + contactList.add(Contact(name, phone, mail, birthday, gender, memo)) } if (contactList.size > 0) { @@ -45,8 +49,22 @@ class ContactMainActivity : AppCompatActivity() { startActivity(intent) } - recyclerView.adapter = RecyclerViewAdapter(contactList, LayoutInflater.from(this)) + val adapter = RecyclerViewAdapter(contactList, LayoutInflater.from(this)) + + recyclerView.adapter = adapter recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) + adapter.setListener(object: RecyclerViewAdapter.ItemClickListener{ + override fun onClick(v: View, position: Int) { + val intent = Intent(this@ContactMainActivity, ContactDetailActivity::class.java) + intent.putExtra("name", contactList.get(position).name) + intent.putExtra("phone", contactList.get(position).phone) + intent.putExtra("mail", contactList.get(position).mail) + intent.putExtra("birthday", contactList.get(position).birthday) + intent.putExtra("gender", contactList.get(position).gender) + intent.putExtra("memo", contactList.get(position).memo) + startActivity(intent) + } + }) } } @@ -71,11 +89,24 @@ class RecyclerViewAdapter( override fun onBindViewHolder(holder: ViewHolder, position: Int) { holder.name.text = contactList.get(position).name holder.profile.text = contactList.get(position).name.substring(0, 1) + + holder.itemView.setOnClickListener { + recyclerListener.onClick(it, position) + } + } + interface ItemClickListener { + fun onClick(v: View, position: Int) } + fun setListener(itemClickListener: ItemClickListener) { + this.recyclerListener = itemClickListener + } + + lateinit var recyclerListener : ItemClickListener + override fun getItemCount(): Int { return contactList.size } } -class Contact(val name: String, val phone: String) \ No newline at end of file +class Contact(val name: String, val phone: String, val mail: String, val birthday: String, val gender: String, val memo: String) \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt index d9e3b327..86d84605 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt @@ -61,10 +61,18 @@ class ContactWritingActivity : AppCompatActivity() { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) intent.putExtra("name", name.text.toString()) intent.putExtra("phone", phone.text.toString()) - //intent.putExtra("mail", mail.text) - //intent.putExtra("birthday", birthday.text) - //intent.putExtra("gender", name.text) //gender 선택한 값으로 - //intent.putExtra("memo", memo.text) + intent.putExtra("mail", mail.text.toString()) + intent.putExtra("birthday", birthday.text) + + if(gender.checkedRadioButtonId == R.id.radioBtn_man) { + intent.putExtra("gender", "남성") + } else if(gender.checkedRadioButtonId == R.id.radioBtn_woman) { + intent.putExtra("gender", "여성") + } else { + intent.putExtra("gender", "") + } + + intent.putExtra("memo", memo.text.toString()) startActivity(intent) } } diff --git a/app/src/main/res/layout/activity_contact_detail.xml b/app/src/main/res/layout/activity_contact_detail.xml new file mode 100644 index 00000000..9dc8795b --- /dev/null +++ b/app/src/main/res/layout/activity_contact_detail.xml @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 9b660be4aa8591bd7bf2c9a44b256dfb6ee65f95 Mon Sep 17 00:00:00 2001 From: anyooin Date: Fri, 28 Jun 2024 14:46:55 +0900 Subject: [PATCH 28/29] refactor : code refactoring --- .../kakao/contacts/ContactDetailActivity.kt | 2 +- .../kakao/contacts/ContactMainActivity.kt | 14 ++++-- .../kakao/contacts/ContactWritingActivity.kt | 25 +++++----- .../res/layout/activity_contact_detail.xml | 48 +++++++++---------- .../main/res/layout/activity_contact_main.xml | 8 ++-- .../res/layout/activity_contact_writing.xml | 6 +-- app/src/main/res/layout/item_contact.xml | 14 +++--- 7 files changed, 64 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactDetailActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactDetailActivity.kt index 89c2fb6d..0ec5e1eb 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactDetailActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactDetailActivity.kt @@ -23,7 +23,7 @@ class ContactDetailActivity : AppCompatActivity() { phoneTextView.text = intent.getStringExtra("phone") mailTextView.text = intent.getStringExtra("mail") birthdayTextView.text = intent.getStringExtra("birthday") - genderTextView.text =intent.getStringExtra("gender") + genderTextView.text = intent.getStringExtra("gender") memoTextView.text = intent.getStringExtra("memo") } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt index 6205031b..ea063d0a 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactMainActivity.kt @@ -53,7 +53,7 @@ class ContactMainActivity : AppCompatActivity() { recyclerView.adapter = adapter recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) - adapter.setListener(object: RecyclerViewAdapter.ItemClickListener{ + adapter.setListener(object : RecyclerViewAdapter.ItemClickListener { override fun onClick(v: View, position: Int) { val intent = Intent(this@ContactMainActivity, ContactDetailActivity::class.java) intent.putExtra("name", contactList.get(position).name) @@ -94,6 +94,7 @@ class RecyclerViewAdapter( recyclerListener.onClick(it, position) } } + interface ItemClickListener { fun onClick(v: View, position: Int) } @@ -102,11 +103,18 @@ class RecyclerViewAdapter( this.recyclerListener = itemClickListener } - lateinit var recyclerListener : ItemClickListener + lateinit var recyclerListener: ItemClickListener override fun getItemCount(): Int { return contactList.size } } -class Contact(val name: String, val phone: String, val mail: String, val birthday: String, val gender: String, val memo: String) \ No newline at end of file +class Contact( + val name: String, + val phone: String, + val mail: String, + val birthday: String, + val gender: String, + val memo: String +) \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt index 86d84605..c8054e10 100644 --- a/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt +++ b/app/src/main/java/campus/tech/kakao/contacts/ContactWritingActivity.kt @@ -64,9 +64,9 @@ class ContactWritingActivity : AppCompatActivity() { intent.putExtra("mail", mail.text.toString()) intent.putExtra("birthday", birthday.text) - if(gender.checkedRadioButtonId == R.id.radioBtn_man) { + if (gender.checkedRadioButtonId == R.id.radioBtn_man) { intent.putExtra("gender", "남성") - } else if(gender.checkedRadioButtonId == R.id.radioBtn_woman) { + } else if (gender.checkedRadioButtonId == R.id.radioBtn_woman) { intent.putExtra("gender", "여성") } else { intent.putExtra("gender", "") @@ -104,7 +104,7 @@ class ContactWritingActivity : AppCompatActivity() { } override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { - if(keyCode == KeyEvent.KEYCODE_BACK) { + if (keyCode == KeyEvent.KEYCODE_BACK) { val name = findViewById(R.id.name) val phone = findViewById(R.id.phone) val mail = findViewById(R.id.mail) @@ -112,11 +112,11 @@ class ContactWritingActivity : AppCompatActivity() { val gender = findViewById(R.id.gender) val memo = findViewById(R.id.memo) - if(checkWriting(name, phone, mail, birthday, gender, memo)) { + if (checkWriting(name, phone, mail, birthday, gender, memo)) { val dialogListener = DialogInterface.OnClickListener { dialog, which -> - if(which == DialogInterface.BUTTON_POSITIVE) { + if (which == DialogInterface.BUTTON_POSITIVE) { Log.d("uin", "작성하기 버튼") - } else if(which == DialogInterface.BUTTON_NEGATIVE) { + } else if (which == DialogInterface.BUTTON_NEGATIVE) { Log.d("uin", "나가기 버튼") val intent = Intent(this, ContactMainActivity::class.java) intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) @@ -136,14 +136,17 @@ class ContactWritingActivity : AppCompatActivity() { } } -fun checkWriting(name : EditText, phone : EditText, mail : EditText, birthday : TextView, - gender : RadioGroup, memo : EditText) : Boolean { - if(name.text.isNotEmpty()|| phone.text.isNotEmpty() || mail.text.isNotEmpty() - || birthday.text.isNotEmpty() || memo.text.isNotEmpty()) { +fun checkWriting( + name: EditText, phone: EditText, mail: EditText, birthday: TextView, + gender: RadioGroup, memo: EditText +): Boolean { + if (name.text.isNotEmpty() || phone.text.isNotEmpty() || mail.text.isNotEmpty() + || birthday.text.isNotEmpty() || memo.text.isNotEmpty() + ) { return true } - if(gender.checkedRadioButtonId != -1) { + if (gender.checkedRadioButtonId != -1) { return true } return false diff --git a/app/src/main/res/layout/activity_contact_detail.xml b/app/src/main/res/layout/activity_contact_detail.xml index 9dc8795b..be40d34f 100644 --- a/app/src/main/res/layout/activity_contact_detail.xml +++ b/app/src/main/res/layout/activity_contact_detail.xml @@ -25,21 +25,21 @@ @@ -53,21 +53,21 @@ @@ -81,21 +81,21 @@ @@ -109,21 +109,21 @@ @@ -137,21 +137,21 @@ @@ -165,21 +165,21 @@ diff --git a/app/src/main/res/layout/activity_contact_main.xml b/app/src/main/res/layout/activity_contact_main.xml index da4b4b65..e5399d00 100644 --- a/app/src/main/res/layout/activity_contact_main.xml +++ b/app/src/main/res/layout/activity_contact_main.xml @@ -5,8 +5,8 @@ android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".ContactMainActivity" - android:orientation="vertical"> + android:orientation="vertical" + tools:context=".ContactMainActivity"> + android:textSize="20sp" /> + android:src="@drawable/baseline_keyboard_arrow_down_24" /> @@ -98,7 +98,7 @@ android:id="@+id/moreInfo" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical" > + android:orientation="vertical"> + android:gravity="center_vertical" + android:padding="15dp"> + android:textSize="20sp" /> From b6d4a12fab8f62784a4e6366432d97c6f820beaf Mon Sep 17 00:00:00 2001 From: anyooin Date: Fri, 28 Jun 2024 15:36:03 +0900 Subject: [PATCH 29/29] docs : update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd3c5921..da90b581 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ - 성별을 둘 중 하나를 선택할 수 있다. - 저장 버튼을 누르면 '저장이 완료 되었습니다' 라는 토스트 메시지를 보여준다. - 취소 버튼을 누르면 '취소 되었습니다' 라는 토스트 메시지를 보여준다. -- + ### 구현할 기능 - 이름을 입력하지 않고 저장버튼 누르면 '이름은 필수값입니다' 토스트 메시지, 포커스도 이름으로 - 전화번호를 입력하지 않고 저장버튼 누르면 '전화번호는 필수값입니다' 토스트 메시지, 포커스도 전화번호로