Skip to content

Commit

Permalink
[Refactor/remote config] 리모트 컨피그 관련 로직 수정 + info 버튼 터치 영역 확대 (#224)
Browse files Browse the repository at this point in the history
* chore: change small size logo file

* delete: infoviewmodelfactory 제거

* chore: modify default config

* chore: modify real location data

* chore: more larger touch area(cafetria info btn)
  • Loading branch information
HI-JIN2 authored Sep 28, 2024
1 parent 6e4f118 commit abf8691
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 277 deletions.
13 changes: 3 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@drawable/img_logo1_44"
android:icon="@drawable/img_logo_512"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:roundIcon="@drawable/img_logo1_44"
android:roundIcon="@drawable/img_logo_512"
android:supportsRtl="true"
android:theme="@style/Theme.EatSSUAndroid"
android:usesCleartextTraffic="true"
Expand Down Expand Up @@ -151,14 +151,7 @@
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".ui.info.InfoActivity"
android:exported="true"
android:theme="@style/Theme.MyDialog">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>

<activity
android:name=".ui.main.MainActivity"
android:exported="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package com.eatssu.android.data.repository

import com.eatssu.android.R
import com.eatssu.android.data.enums.Restaurant
import com.eatssu.android.data.model.AndroidMessage
import com.eatssu.android.data.model.RestaurantInfo
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings
import com.google.gson.Gson
import org.json.JSONArray
import timber.log.Timber

Expand Down Expand Up @@ -41,25 +39,25 @@ class FirebaseRemoteConfigRepository {
}
}

fun getAndroidMessage(): AndroidMessage {

// Gson을 사용하여 JSON 문자열을 DTO로 파싱
val serverStatus: AndroidMessage = Gson().fromJson(instance.getString("android_message"), AndroidMessage::class.java)

// 파싱된 결과 확인
println("Dialog: ${serverStatus.dialog}")
println("Message: ${serverStatus.message}")

return serverStatus
}

fun getForceUpdate(): Boolean {
return instance.getBoolean("force_update")
}

fun getAppVersion(): String {
return instance.getString("app_version")
}
// fun getAndroidMessage(): AndroidMessage {
//
// // Gson을 사용하여 JSON 문자열을 DTO로 파싱
// val serverStatus: AndroidMessage = Gson().fromJson(instance.getString("android_message"), AndroidMessage::class.java)
//
// // 파싱된 결과 확인
// println("Dialog: ${serverStatus.dialog}")
// println("Message: ${serverStatus.message}")
//
// return serverStatus
// }

// fun getForceUpdate(): Boolean {
// return instance.getBoolean("force_update")
// }
//
// fun getAppVersion(): String {
// return instance.getString("app_version")
// }

fun getVersionCode(): Long {
return instance.getLong("android_version_code")
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/eatssu/android/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.eatssu.android.di

import android.app.Application
import android.content.Context
import com.eatssu.android.data.repository.FirebaseRemoteConfigRepository
import com.eatssu.android.data.repository.PreferencesRepository
import dagger.Module
import dagger.Provides
Expand All @@ -25,4 +26,11 @@ object AppModule {
fun providePreferencesRepository(@ApplicationContext context: Context): PreferencesRepository {
return PreferencesRepository(context)
}


@Provides
@Singleton
fun provideFirebaseRemoteConfigRepository(): FirebaseRemoteConfigRepository {
return FirebaseRemoteConfigRepository()
}
}
69 changes: 0 additions & 69 deletions app/src/main/java/com/eatssu/android/ui/info/InfoActivity.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,117 +1,66 @@
package com.eatssu.android.ui.info

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import androidx.fragment.app.activityViewModels
import com.bumptech.glide.Glide
import com.eatssu.android.data.enums.Restaurant
import com.eatssu.android.data.repository.FirebaseRemoteConfigRepository
import com.eatssu.android.databinding.FragmentBottomsheetInfoBinding
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import timber.log.Timber

class InfoBottomSheetFragment : BottomSheetDialogFragment() {
private var _binding: FragmentBottomsheetInfoBinding? = null
private val binding get() = _binding!!

private lateinit var infoViewModel: InfoViewModel
private lateinit var firebaseRemoteConfigRepository: FirebaseRemoteConfigRepository

private val infoViewModel: InfoViewModel by activityViewModels()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
_binding = FragmentBottomsheetInfoBinding.inflate(inflater, container, false)

firebaseRemoteConfigRepository = FirebaseRemoteConfigRepository()
infoViewModel = ViewModelProvider(
this,
InfoViewModelFactory(firebaseRemoteConfigRepository)
)[InfoViewModel::class.java]

return binding.root
}


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

// 전달된 데이터 받기
// Retrieve passed data
val name = arguments?.getString("name")
val restaurantType = enumValues<Restaurant>().find { it.name == name } ?: Restaurant.HAKSIK
Log.d("InfoBottomSheetFragment", "onViewCreated: $name $restaurantType")
Timber.d("onViewCreated: $name $restaurantType")

binding.tvName.text = restaurantType.displayName

//TODO 방법 개선
infoViewModel.infoList.observe(this) {
// Collect the infoList Flow
CoroutineScope(Dispatchers.Main).launch {
infoViewModel.infoList.collect { restaurantInfoList ->
val restaurantInfo = infoViewModel.getRestaurantInfo(restaurantType)

when (restaurantType) {
Restaurant.DODAM -> {
binding.tvLocation.text = infoViewModel.dodamLocation.value
binding.tvTime.text = infoViewModel.dodamTime.value
binding.tvEtc.text = infoViewModel.dodamEtc.value
restaurantInfo?.let {
binding.tvLocation.text = it.location
binding.tvTime.text = it.time
binding.tvEtc.text = it.etc

Glide.with(this)
.load(infoViewModel.dodamPhotoUrl.value)
Glide.with(this@InfoBottomSheetFragment)
.load(it.photoUrl)
.into(binding.ivCafeteriaPhoto)
}

Restaurant.HAKSIK -> {
binding.tvLocation.text = infoViewModel.haksikLocation.value
binding.tvTime.text = infoViewModel.haksikTime.value
binding.tvEtc.text = infoViewModel.haksikEtc.value

Glide.with(this)
.load(infoViewModel.haksikPhotoUrl.value)
.into(binding.ivCafeteriaPhoto)
}

Restaurant.FOOD_COURT -> {
binding.tvLocation.text = infoViewModel.foodLocation.value
binding.tvTime.text = infoViewModel.foodTime.value
binding.tvEtc.text = infoViewModel.foodEtc.value

Glide.with(this)
.load(infoViewModel.foodPhotoUrl.value)
.into(binding.ivCafeteriaPhoto)
}

Restaurant.SNACK_CORNER -> {
binding.tvLocation.text = infoViewModel.snackLocation.value
binding.tvTime.text = infoViewModel.snackTime.value
binding.tvEtc.text = infoViewModel.snackEtc.value

Glide.with(this)
.load(infoViewModel.snackPhotoUrl.value)
.into(binding.ivCafeteriaPhoto)
}

Restaurant.DORMITORY -> {
binding.tvLocation.text = infoViewModel.dormitoryLocation.value
binding.tvTime.text = infoViewModel.dormitoryTime.value
binding.tvEtc.text = infoViewModel.dormitoryEtc.value

Glide.with(this)
.load(infoViewModel.dormitoryPhotoUrl.value)
.into(binding.ivCafeteriaPhoto)
}

else -> {}
}
}
}

companion object {
// newInstance 메서드를 통해 데이터를 전달하는 방법
fun newInstance(data: String): InfoBottomSheetFragment {
val fragment = InfoBottomSheetFragment()
val args = Bundle()
args.putString("name", data)
val args = Bundle().apply { putString("name", data) }
fragment.arguments = args
return fragment
}
Expand Down
Loading

0 comments on commit abf8691

Please sign in to comment.