Skip to content

Commit

Permalink
Merge pull request #76 from EAT-SSU/72-hotfix-today-menu-force-quit
Browse files Browse the repository at this point in the history
[hotfix] 카카오 로그인/다중메뉴 꺼짐 해결
  • Loading branch information
HI-JIN2 authored Oct 31, 2023
2 parents f2c2f6b + a491ba5 commit 9c07c02
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 261 deletions.
40 changes: 14 additions & 26 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,25 @@ plugins {

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def BASE_URL = properties.getProperty('BASE_URL')
def KAKAO_NATIVE_APP_KEY = properties.getProperty('KAKAO_NATIVE_APP_KEY')
def KAKAO_REDIRECTION_SCHEME = properties.getProperty('KAKAO_REDIRECTION_SCHEME')



android {
namespace 'com.eatssu.android'
compileSdk 33
// compileSdkVersion 33 // 원하는 SDK 버전으로 변경하세요
compileSdk 34

defaultConfig {
applicationId "com.eatssu.android"
minSdk 21
compileSdkVersion 33
targetSdk 33
compileSdkVersion 34
targetSdk 34
versionCode 1
versionName "1.0"


buildConfigField "String", "BASE_URL", properties["BASE_URL"]

buildConfigField("String", "BASE_URL", BASE_URL)
manifestPlaceholders = [BASE_URL: BASE_URL]

buildConfigField("String", "KAKAO_NATIVE_APP_KEY", KAKAO_NATIVE_APP_KEY)
manifestPlaceholders = [KAKAO_NATIVE_APP_KEY: KAKAO_NATIVE_APP_KEY]

buildConfigField("String", "KAKAO_REDIRECTION_SCHEME", KAKAO_REDIRECTION_SCHEME)
manifestPlaceholders = [KAKAO_REDIRECTION_SCHEME: KAKAO_REDIRECTION_SCHEME]
buildConfigField("String", "KAKAO_NATIVE_APP_KEY", "\"${properties.get('KAKAO_NATIVE_APP_KEY')}\"")
manifestPlaceholders = [KAKAO_NATIVE_APP_KEY: properties.get('KAKAO_NATIVE_APP_KEY')]

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -51,11 +41,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
splits {
abi {
Expand Down Expand Up @@ -108,10 +98,8 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'

// implementation group: 'com.kakao.sdk', name: 'usermgmt', version: '1.30.0'
// implementation group: 'com.kakao.sdk', name: 'kakaolink', version: '1.30.5'

implementation "com.kakao.sdk:v2-user:2.5.0" // 카카오 로그인
// 카카오 로그인 모듈
implementation "com.kakao.sdk:v2-user:2.8.6" // 카카오 로그인

implementation 'com.google.dagger:hilt-android:2.47'
annotationProcessor 'com.google.dagger:hilt-compiler:2.47'
Expand All @@ -120,12 +108,12 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.1"

implementation 'androidx.activity:activity-ktx:1.1.0'
implementation 'androidx.fragment:fragment-ktx:1.2.5'
implementation 'androidx.activity:activity-ktx:1.8.0'
implementation 'androidx.fragment:fragment-ktx:1.6.1'

// implementation "androidx.security:security-crypto:1.0.0"

implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.github.bumptech.glide:glide:4.15.1'
// kapt 'com.github.bumptech.glide:compiler:4.12.0'

implementation 'id.zelory:compressor:3.0.1'
Expand Down
18 changes: 7 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@
android:value="" />
</activity>

<meta-data
android:name="com.kakao.sdk.AppKey"
android:value="$kakao_native_app_key" /> <!-- <meta-data -->
<!-- android:name="com.kakao.sdk.AppKey" -->
<!-- android:value="${APP_KEY}" /> -->


<activity
android:name=".view.main.ForceUpdateDialogActivity"
Expand All @@ -74,21 +70,21 @@
android:name="android.app.lib_name"
android:value="" />
</activity>
<!-- <meta-data-->
<!-- android:name="com.kakao.sdk.AppKey"-->
<!-- android:value="$KAKAO_NATIVE_APP_KEY" />-->

<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true"
android:launchMode="singleTask">
android:exported="true">
<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_REDIRECTION_SCHEME}" />
</intent-filter>
android:scheme="kakao${KAKAO_NATIVE_APP_KEY}" /> </intent-filter>
</activity>
<activity
android:name=".base.BaseActivity"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/eatssu/android/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class App: Application() {

token_prefs = TokenSharedPreferences(applicationContext)

val apiKey = BuildConfig.KAKAO_NATIVE_APP_KEY
// val apiKey = BuildConfig.KAKAO_NATIVE_APP_KEY

appContext = this
KakaoSdk.init(this,BuildConfig.KAKAO_NATIVE_APP_KEY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ class TodayMealAdapter(private val dataList: GetTodayMealResponseDto) :
intent.putExtra("menuIdArray",menuIdArray)
intent.putStringArrayListExtra("menuNameArray",menuNameArray)

intent.putStringArrayListExtra("itemName", dataList[position].changeMenuInfoList as java.util.ArrayList<String>)

ContextCompat.startActivity(holder.itemView.context, intent, null)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.eatssu.android.data.enums

enum class Restaurant (val displayName: String){
DODAM("도담 식당"),
DOMITORY("기숙사 식당"),
DORMITORY("기숙사 식당"),
FOOD_COURT("푸드 코트",),
SNACK_CORNER("스낵 코너"),
HAKSIK("학생 식당"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class InfoActivity_Gisik : AppCompatActivity(){
}
mapview.addPOIItem(marker)

getRestaurantInfo(Restaurant.DOMITORY)
getRestaurantInfo(Restaurant.DORMITORY)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package com.eatssu.android.view.login
import android.content.ContentValues.TAG
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.webkit.WebView
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat.startActivity
import androidx.lifecycle.lifecycleScope
import com.eatssu.android.App
import com.eatssu.android.data.MySharedPreferences
Expand All @@ -17,6 +20,7 @@ import com.eatssu.android.data.model.response.TokenResponseDto
import com.eatssu.android.data.service.OauthService
import com.eatssu.android.databinding.ActivitySocialLoginBinding
import com.eatssu.android.view.main.MainActivity
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
Expand All @@ -30,61 +34,15 @@ import java.net.URISyntaxException
class SocialLoginActivity : AppCompatActivity() {
private lateinit var binding: ActivitySocialLoginBinding

// 코틀린
fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
if (url != null && url.startsWith("intent://")) {
try {
val intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME)
val existPackage =
packageManager.getLaunchIntentForPackage(intent.getPackage()!!)
if (existPackage != null) {
startActivity(intent)
} else {
val marketIntent = Intent(Intent.ACTION_VIEW)
marketIntent.data =
Uri.parse("market://details?id=" + intent.getPackage()!!)
startActivity(marketIntent)
}
return true
} catch (e: Exception) {
e.printStackTrace()
}

} else if (url != null && url.startsWith("market://")) {
try {
val intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME)
if (intent != null) {
startActivity(intent)
}
return true
} catch (e: URISyntaxException) {
e.printStackTrace()
}

}
view.loadUrl(url)
return false
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySocialLoginBinding.inflate(layoutInflater)
setContentView(binding.root)

//카카오 로그인에서 제공하는 자동로그인 메소드
// UserApiClient.instance.accessTokenInfo { tokenInfo, error ->
// if (error != null) {
// Toast.makeText(this, "자동 로그인 실패", Toast.LENGTH_SHORT).show()
// }
// else if (tokenInfo != null) {
// Toast.makeText(this, "자동 로그인 성공", Toast.LENGTH_SHORT).show()
// val intent = Intent(this, MainActivity::class.java)
// startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
// }
// }

// SharedPreferences 안에 값이 저장되어 있을 때-> Login 패스하기
if (MySharedPreferences.getUserEmail(this).isNotBlank()){// SharedPreferences 안에 값이 저장되어 있을 때 -> MainActivity로 이동
if (MySharedPreferences.getUserEmail(this).isNotBlank()) {
// SharedPreferences 안에 값이 저장되어 있을 때 -> MainActivity로 이동
Toast.makeText(
this,
"자동 로그인 되었습니다.",
Expand All @@ -97,7 +55,10 @@ class SocialLoginActivity : AppCompatActivity() {

val context = this


binding.imbKakao.setOnClickListener {

Log.d("post", "버튼 클릭")
lifecycleScope.launch {
try {
// 서비스 코드에서는 간단하게 로그인 요청하고 oAuthToken 을 받아올 수 있다.
Expand All @@ -114,14 +75,9 @@ class SocialLoginActivity : AppCompatActivity() {
}
}
}
//둘러보기 MVP에서 제외
// binding.btnLookAround.setOnClickListener() {
// val intent = Intent(this, MainActivity::class.java) // 인텐트를 생성해줌,
// startActivity(intent) // 화면 전환을 시켜줌
// finish()
// }
}


private fun postUserInfo() {
UserApiClient.instance.me { user, error ->
if (user != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.eatssu.android.data.enums.Time
import com.eatssu.android.data.service.MenuService
import com.eatssu.android.data.service.ReviewService
import com.eatssu.android.databinding.FragmentBreakfastBinding
import com.eatssu.android.databinding.FragmentDinnerBinding
import com.eatssu.android.repository.MenuRepository
import com.eatssu.android.repository.ReviewRepository
import com.eatssu.android.view.infopage.*
Expand All @@ -29,7 +28,6 @@ import com.eatssu.android.viewmodel.ReviewViewModel
import com.eatssu.android.viewmodel.factory.MenuViewModelFactory
import com.eatssu.android.viewmodel.factory.ReviewViewModelFactory
//import com.eatssu.android.adapter.DodamAdapter
import retrofit2.Retrofit
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

Expand Down Expand Up @@ -105,7 +103,7 @@ class BreakfastFragment : Fragment() {
// })

//기숙사식당
viewModel.loadTodayMeal(menuDate, Restaurant.DOMITORY, Time.LUNCH)
viewModel.loadTodayMeal(menuDate, Restaurant.DORMITORY, Time.MORNING)
viewModel.todayMealDataDormitory.observe(viewLifecycleOwner, Observer { result ->
//if (result.toString() != "[]") {
val dodamAdapter = TodayMealAdapter(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.annotation.RequiresApi
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.eatssu.android.adapter.FixedMenuAdapter
import com.eatssu.android.adapter.TodayMealAdapter
import com.eatssu.android.data.RetrofitImpl.retrofit
import com.eatssu.android.data.enums.Restaurant
Expand All @@ -21,7 +20,6 @@ import com.eatssu.android.data.enums.Time
import com.eatssu.android.data.service.MenuService
import com.eatssu.android.data.service.ReviewService
import com.eatssu.android.databinding.FragmentDinnerBinding
import com.eatssu.android.databinding.FragmentLunchBinding
import com.eatssu.android.repository.MenuRepository
import com.eatssu.android.repository.ReviewRepository
import com.eatssu.android.view.infopage.*
Expand All @@ -31,7 +29,6 @@ import com.eatssu.android.viewmodel.ReviewViewModel
import com.eatssu.android.viewmodel.factory.MenuViewModelFactory
import com.eatssu.android.viewmodel.factory.ReviewViewModelFactory
import dagger.hilt.android.AndroidEntryPoint
import retrofit2.Retrofit
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

Expand Down Expand Up @@ -89,7 +86,7 @@ class DinnerFragment : Fragment() {
menuDate =
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMM")) + dataReceived
//숭실도담
viewModel.loadTodayMeal(menuDate, Restaurant.DODAM, Time.LUNCH)
viewModel.loadTodayMeal(menuDate, Restaurant.DODAM, Time.DINNER)
viewModel.todayMealDataDodam.observe(viewLifecycleOwner, Observer { result ->
//if (result.toString() != "[]") {
val dodamAdapter = TodayMealAdapter(result)
Expand All @@ -107,7 +104,7 @@ class DinnerFragment : Fragment() {
})

//기숙사식당
viewModel.loadTodayMeal(menuDate, Restaurant.DOMITORY, Time.LUNCH)
viewModel.loadTodayMeal(menuDate, Restaurant.DORMITORY, Time.DINNER)
viewModel.todayMealDataDormitory.observe(viewLifecycleOwner, Observer { result ->
//if (result.toString() != "[]") {
val dodamAdapter = TodayMealAdapter(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class LunchFragment : Fragment() {
})

//기숙사식당
viewModel.loadTodayMeal(menuDate, Restaurant.DOMITORY, Time.LUNCH)
viewModel.loadTodayMeal(menuDate, Restaurant.DORMITORY, Time.LUNCH)
viewModel.todayMealDataDormitory.observe(viewLifecycleOwner, Observer { result ->
//if (result.toString()!= "[]") {
val dodamAdapter = TodayMealAdapter(result)
Expand Down Expand Up @@ -171,6 +171,11 @@ class LunchFragment : Fragment() {
setupClickListeners() //info dialog
}

override fun onResume() {
super.onResume()

}


private fun setupClickListeners() {
binding.btnHaksikInfo.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class MainActivity : AppCompatActivity() {
Log.d("post", "onResponse 성공: " + response.body().toString());
nickname = response.body()?.nickname.toString()
//나중에 isNullOrBlank로 바꿀 것
if (nickname == "KAKAO유저") {
if (nickname == null) {
startActivity(intentNick)
}
}
Expand Down
Loading

0 comments on commit 9c07c02

Please sign in to comment.