Skip to content

Commit

Permalink
Merge branch 'feat/#4_wishList_select' into feat/#1
Browse files Browse the repository at this point in the history
  • Loading branch information
codeSweet0828 authored Jan 23, 2024
2 parents 9f3a597 + 349884d commit 279a202
Show file tree
Hide file tree
Showing 47 changed files with 889 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
.externalNativeBuild
.cxx
local.properties

.idea/
api.properties
manifest-api.properties
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ android {
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

loadProperties("api.properties").each {
buildConfigField("String", it.key, it.value)
}

def properties = new Properties()
def localPropertiesFile = rootProject.file('manifest-api.properties')
if (localPropertiesFile.exists()) {
properties.load(new FileInputStream(localPropertiesFile))
def nativeAppKey = properties['NATIVE_APP_KEY'] ?: ""
manifestPlaceholders = [nativeAppKey: nativeAppKey]
}
}

buildFeatures {
buildConfig = true
}

buildTypes {
Expand All @@ -30,9 +46,20 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}

buildFeatures {
viewBinding true
}
}

dependencies {
// Kakao SDK
implementation "com.kakao.sdk:v2-user:2.19.0"

// retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
Expand All @@ -42,4 +69,10 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

static def loadProperties(String file) {
Properties properties = new Properties()
properties.load(new FileInputStream(file))
return properties
}
48 changes: 36 additions & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<!-- 인터넷 사용 권한 설정 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".GlobalApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -11,24 +16,43 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Android"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".sample.SampleActivity"
android:exported="false">
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
</activity>
<activity
android:name=".home.LoginActivity"
android:exported="false">
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
</activity>
<activity
android:name=".wish.WishList"
android:exported="true">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->

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

<activity
android:name=".wish.WishInsertActivity"
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Redirect URI: "kakao${NATIVE_APP_KEY}://oauth" -->
<data android:host="oauth"
android:scheme="kakao${nativeAppKey}" />
</intent-filter>
</activity>
</application>
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/wish/bunny/GlobalApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.wish.bunny

import android.app.Application
/*import com.kakao.sdk.common.KakaoSdk
import com.wish.bunny.BuildConfig.NATIVE_APP_KEY*/

/**
작성자: 엄상은
처리 내용: 카카오 로그인 SDK 초기화
*/
class GlobalApplication : Application() {
override fun onCreate() {
super.onCreate()
// Kakao SDK 초기화
// KakaoSdk.init(this, "${NATIVE_APP_KEY}")
}
}
37 changes: 35 additions & 2 deletions app/src/main/java/com/wish/bunny/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
package com.wish.bunny

import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.appcompat.app.AppCompatActivity
import android.util.Log
import com.kakao.sdk.common.util.Utility
import com.wish.bunny.databinding.ActivityMainBinding
import com.wish.bunny.friend.FriendFragment
import com.wish.bunny.home.HomeFragment
import com.wish.bunny.mypage.MypageFragment

class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater) // 뷰 바인딩
setContentView(binding.root)
var keyhash = Utility.getKeyHash(this)
Log.d("MainActivity", keyhash)

binding.bottomNavi.run { setOnNavigationItemSelectedListener {
when(it.itemId) {
R.id.navi_home -> {
// 다른 프래그먼트 화면으로 이동하는 기능
val homeFragment = HomeFragment()
supportFragmentManager.beginTransaction().replace(R.id.fragment_container, homeFragment).commit()
}
R.id.navi_friend -> {
val boardFragment = FriendFragment()
supportFragmentManager.beginTransaction().replace(R.id.fragment_container, boardFragment).commit()
}
R.id.navi_mypage -> {
val settingFragment = MypageFragment()
supportFragmentManager.beginTransaction().replace(R.id.fragment_container, settingFragment).commit()
}
}
true
}
selectedItemId = R.id.navi_home
}
}



}
23 changes: 23 additions & 0 deletions app/src/main/java/com/wish/bunny/friend/FriendFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.wish.bunny.friend

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.wish.bunny.R

class FriendFragment : Fragment() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_friend, container, false)
}
}
22 changes: 22 additions & 0 deletions app/src/main/java/com/wish/bunny/home/HomeFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.wish.bunny.home

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.wish.bunny.R

class HomeFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_friend, container, false)
}
}
55 changes: 55 additions & 0 deletions app/src/main/java/com/wish/bunny/home/LoginActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.wish.bunny.home

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.ImageView
import com.kakao.sdk.auth.model.OAuthToken
import com.kakao.sdk.common.model.ClientError
import com.kakao.sdk.common.model.ClientErrorCause
import com.kakao.sdk.user.UserApiClient
import com.wish.bunny.R

/**
작성자: 엄상은
처리 내용: 카카오 로그인 액티비티
*/
class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
val kakaoLoginButton = findViewById<ImageView>(R.id.kakao_login)

kakaoLoginButton.setOnClickListener {
// 카카오계정으로 로그인 공통 callback 구성
// 카카오톡으로 로그인 할 수 없어 카카오계정으로 로그인할 경우 사용됨
val callback: (OAuthToken?, Throwable?) -> Unit = { token, error ->
if (error != null) {
Log.e("KAKAO LOGIN", "카카오계정으로 로그인 실패", error)
} else if (token != null) {
Log.i("KAKAO LOGIN", "카카오계정으로 로그인 성공 ${token.accessToken}")
}
}

// 카카오톡이 설치되어 있으면 카카오톡으로 로그인, 아니면 카카오계정으로 로그인
if (UserApiClient.instance.isKakaoTalkLoginAvailable(this)) {
UserApiClient.instance.loginWithKakaoTalk(this) { token, error ->
if (error != null) {
Log.e("KAKAO LOGIN", "카카오톡으로 로그인 실패", error)
// 사용자가 카카오톡 설치 후 디바이스 권한 요청 화면에서 로그인을 취소한 경우,
// 의도적인 로그인 취소로 보고 카카오계정으로 로그인 시도 없이 로그인 취소로 처리 (예: 뒤로 가기)
if (error is ClientError && error.reason == ClientErrorCause.Cancelled) {
return@loginWithKakaoTalk
}
// 카카오톡에 연결된 카카오계정이 없는 경우, 카카오계정으로 로그인 시도
UserApiClient.instance.loginWithKakaoAccount(this, callback = callback)
} else if (token != null) {
Log.i("KAKAO LOGIN", "카카오톡으로 로그인 성공 ${token.accessToken}")
}
}
} else {
UserApiClient.instance.loginWithKakaoAccount(this, callback = callback)
}
}
}
}
22 changes: 22 additions & 0 deletions app/src/main/java/com/wish/bunny/mypage/MypageFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.wish.bunny.mypage

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.wish.bunny.R

class MypageFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_friend, container, false)
}
}
25 changes: 25 additions & 0 deletions app/src/main/java/com/wish/bunny/retrofit/RetrofitConnection.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.wish.bunny.retrofit

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

/**
작성자: 엄상은
처리 내용: 레트로핏 연결 설정 (싱글톤 객체)
*/
class RetrofitConnection {
companion object {
private const val BASE_URL = "http://10.0.2.2:8080/"
private var INSTANCE: Retrofit? = null

fun getInstance(): Retrofit {
if (INSTANCE == null) {
INSTANCE = Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
}
return INSTANCE!!
}
}
}
Loading

0 comments on commit 279a202

Please sign in to comment.