Skip to content

Commit

Permalink
Merge pull request #33 from ttoklip/feat/#15_첫화면로그인_구현
Browse files Browse the repository at this point in the history
Feat/#15 첫화면로그인 구현
  • Loading branch information
hangunhee39 authored Feb 6, 2024
2 parents 5728de7 + 243e0f2 commit 53aa8a4
Show file tree
Hide file tree
Showing 54 changed files with 2,175 additions and 985 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ dependencies {
implementation 'com.google.android.flexbox:flexbox:3.0.0'

//naver map
//implementation "com.naver.maps:map-sdk:3.16.2"
implementation "com.naver.maps:map-sdk:3.17.0"
implementation "com.google.android.gms:play-services-location:21.1.0"
}
kapt {
correctErrorTypes true
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />


<application
android:name=".TtoklipApplication"
android:allowBackup="true"
Expand All @@ -20,6 +21,10 @@
android:usesCleartextTraffic="true"
tools:targetApi="31">

<meta-data
android:name="com.naver.maps.map.CLIENT_ID"
android:value="a6zjlu88zi"/>

<activity
android:name=".presentation.mypage.ManageMyInfoActivity"
android:screenOrientation="portrait"
Expand Down Expand Up @@ -84,6 +89,10 @@
android:exported="false"/>
<activity android:name=".presentation.signup.SignupActivity"
android:exported="false"/>
<activity android:name=".presentation.signup.LocationActivity"
android:exported="false"/>
<activity android:name=".presentation.signup.DirectLocationActivity"
android:exported="false"/>

<activity
android:name=".presentation.intro.SplashActivity"
Expand All @@ -96,15 +105,6 @@
<activity
android:name=".presentation.MainActivity"
android:exported="false"/>
<!-- <activity-->
<!-- android:name=".presentation.MainActivity"-->
<!-- android:exported="true">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->

<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
<!-- </activity>-->

<service
android:name="com.google.android.gms.metadata.ModuleDependencies"
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/umc/ttoklip/data/api/KakaoApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.umc.ttoklip.data.api

import com.umc.ttoklip.R
import com.umc.ttoklip.data.model.KakaoResponse
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Query

interface KakaoApi {
@GET("v2/local/search/keyword.json")
fun getSearchKeyword(
@Header("Authorization") key: String,
@Query("query") query:String
): Call<KakaoResponse.ResultSearchKeyword>
}
15 changes: 15 additions & 0 deletions app/src/main/java/com/umc/ttoklip/data/model/KakaoResponse.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.umc.ttoklip.data.model

class KakaoResponse{
data class ResultSearchKeyword(
var documents: List<Place> // 검색 결과
)
data class Place(
var id: String, // 장소 ID
var place_name: String, // 장소명, 업체명
var address_name: String, // 전체 지번 주소
var road_address_name: String, // 전체 도로명 주소
var x: String, // X 좌표값 혹은 longitude
var y: String // Y 좌표값 혹은 latitude
)
}
30 changes: 30 additions & 0 deletions app/src/main/java/com/umc/ttoklip/di/appModul.kt
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
package com.umc.ttoklip.di

import com.umc.ttoklip.R
import com.umc.ttoklip.data.api.KakaoApi
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create

@Module
@InstallIn(SingletonComponent::class)
object appModul {
class kakaoAddress {
companion object {
var BASE_URL = R.string.kakao.toString()
var API_KEY = R.string.kakao_api_key.toString()
}

object kakaoApiRetrofitClient {
private val retrofit: Retrofit.Builder by lazy {
Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
}
val apiService: KakaoApi by lazy {
retrofit.build().create(KakaoApi::class.java)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class IntroActivity:BaseActivity<ActivityIntroBinding>(R.layout.activity_intro){
override fun initView() {
binding.introIntroVp.apply {
adapter=IntroVPAdapter(this@IntroActivity,3)
registerOnPageChangeCallback(object:ViewPager2.OnPageChangeCallback(){
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
when(position){
2->binding.introNextBtn.text="똑립 시작하기"
else->binding.introNextBtn.text="다음"
}
}
})
// registerOnPageChangeCallback(object:ViewPager2.OnPageChangeCallback(){
// override fun onPageSelected(position: Int) {
// super.onPageSelected(position)
// when(position){
// 2->binding.introNextBtn.text="똑립 시작하기"
// else->binding.introNextBtn.text="다음"
// }
// }
// })
}
binding.introIndicator.attachTo(binding.introIntroVp)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.umc.ttoklip.presentation.intro

import android.graphics.Typeface
import android.os.Bundle
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.StyleSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -17,13 +21,16 @@ class IntroFragment(val position:Int): Fragment() {
binding=FragmentIntroBinding.inflate(inflater,container,false)

when (position){
0->{binding.itemIntroTitleTv.text="우리, 꿀팁 공유해요!"
binding.itemIntroDescTv.text="독립생활을 하는데 어려운 점을 공유하고\n도움을 주며 해결해봐요"
0->{val spannable=SpannableStringBuilder("어려움과 도움을 함께\n독립생활의 꿀팁공유")
spannable.setSpan(StyleSpan(Typeface.BOLD),11,22, Spannable.SPAN_EXCLUSIVE_INCLUSIVE)
binding.itemIntroTitleTv.text=spannable
/**인앱화면 연결 필요**/}
1->{binding.itemIntroTitleTv.text="오늘은 또 어떤 정보가?"
binding.itemIntroDescTv.text="독립생활을 하는데 필요한 유용한\n정보들을 받아봐요"}
else->{binding.itemIntroTitleTv.text="우리 동네 안에서 서로서로"
binding.itemIntroDescTv.text="우리 동네 똑립이들과 친해지고, 공구하고,\n음식 배달비도 아껴봐요"}
1->{val spannable=SpannableStringBuilder("자취에 도움되는\n최신뉴스를 한눈에")
spannable.setSpan(StyleSpan(Typeface.BOLD),8,13, Spannable.SPAN_EXCLUSIVE_INCLUSIVE)
binding.itemIntroTitleTv.text=spannable}
else->{val spannable=SpannableStringBuilder("혼자서는 비싸,\n동네친구들과 함께")
spannable.setSpan(StyleSpan(Typeface.BOLD),15,18, Spannable.SPAN_EXCLUSIVE_INCLUSIVE)
binding.itemIntroTitleTv.text=spannable}
}

return binding.root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.umc.ttoklip.presentation.login

import android.content.Intent
import android.content.SharedPreferences
import android.text.InputType
import android.view.View
import com.umc.ttoklip.R
import com.umc.ttoklip.databinding.ActivityLoginBinding
import com.umc.ttoklip.presentation.MainActivity
Expand All @@ -11,48 +13,16 @@ import com.umc.ttoklip.presentation.signup.SignupActivity
class LoginActivity:BaseActivity<ActivityLoginBinding>(R.layout.activity_login) {

private var isSaveId:Boolean=false
private var isShowPw:Boolean=false

override fun initView() {
val spf=getSharedPreferences("id", MODE_PRIVATE)
loadSaveId(spf)
binding.loginLoginBtn.setOnClickListener {
setSaveId(isSaveId,spf)
binding.loginNaverBtn.setOnClickListener {
//임시로 연결
startActivity(Intent(this, MainActivity::class.java))
}
binding.loginSignupBtn.setOnClickListener {
binding.loginKakaoBtn.setOnClickListener {
startActivity(Intent(this, SignupActivity::class.java))
}
binding.loginSaveIdIv.setOnClickListener {
setSaveIdStatus(!isSaveId)
}
}

private fun loadSaveId(spf: SharedPreferences) {
isSaveId=spf.getBoolean("saveIdCheck",false)
setSaveIdStatus(isSaveId)
binding.loginIdEt.setText(spf.getString("idString",""))
}
private fun setSaveId(isSaveId: Boolean, spf: SharedPreferences){
val editor=spf.edit()
if (isSaveId){//나중에 로그인 ok도 조건으로 달기
editor.putBoolean("saveIdCheck",true)
editor.putString("idString",binding.loginIdEt.text.toString().trim())
editor.apply()
}else{
editor.putBoolean("saveIdCheck",false)
editor.remove("idString")
editor.apply()
}
}

private fun setSaveIdStatus(isSaveId: Boolean) {
if(isSaveId){
this.isSaveId=true
binding.loginSaveIdIv.setImageResource(R.drawable.ic_check_on_20)
}else{
this.isSaveId=false
binding.loginSaveIdIv.setImageResource(R.drawable.ic_check_off_20)
}
}

override fun onBackPressed() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.umc.ttoklip.presentation.signup

import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.umc.ttoklip.R
import com.umc.ttoklip.data.model.KakaoResponse
import com.umc.ttoklip.databinding.ActivityDirectLocationBinding
import com.umc.ttoklip.di.appModul
import com.umc.ttoklip.presentation.base.BaseActivity
import retrofit2.Call
import retrofit2.Response

class DirectLocationActivity :
BaseActivity<ActivityDirectLocationBinding>(R.layout.activity_direct_location) {
private val kakaoInfo = appModul.kakaoAddress.Companion
private val kakaoApi = appModul.kakaoAddress.kakaoApiRetrofitClient.apiService

override fun initView() {
callKakaoSearch("서울시 관악구 조원로12길 28")
}

fun callKakaoSearch(address: String) {
val kakao = MutableLiveData<KakaoResponse.ResultSearchKeyword>()
kakaoApi.getSearchKeyword(kakaoInfo.API_KEY, query = address)
.enqueue(object : retrofit2.Callback<KakaoResponse.ResultSearchKeyword> {
override fun onResponse(
call: Call<KakaoResponse.ResultSearchKeyword>,
response: Response<KakaoResponse.ResultSearchKeyword>
) {
kakao.value = response.body()
Log.i("kakao", "${kakao.value!!.documents[0].address_name}")
}

override fun onFailure(
call: Call<KakaoResponse.ResultSearchKeyword>,
t: Throwable
) {
t.printStackTrace()
}
})
}

override fun initObserver() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.umc.ttoklip.presentation.signup

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.umc.ttoklip.data.model.KakaoResponse
import com.umc.ttoklip.databinding.ItemAddressBinding

class DirectLocationRVAdapter(private val addressList:List<KakaoResponse.Place>):RecyclerView.Adapter<DirectLocationRVAdapter.ViewHolder>() {
inner class ViewHolder(val binding:ItemAddressBinding):RecyclerView.ViewHolder(binding.root){
fun bind(place:KakaoResponse.Place){
binding.itemAddressTitleTv.text=place.place_name
binding.itemAddressDetailTv.text=place.address_name
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding:ItemAddressBinding=ItemAddressBinding.inflate(LayoutInflater.from(parent.context),parent,false)
return ViewHolder(binding)
}

override fun getItemCount(): Int=addressList.size

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(addressList[position])
}
}
Loading

0 comments on commit 53aa8a4

Please sign in to comment.