-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 바텀 네비게이션 도입 및 기존 캘린더 및 마이페이지 화면 fragment 로 전환 #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
63fba88
[feat] 바텀 네비 세팅 중 임시 커밋
kangyuri1114 4a5f5c0
[feat] 바텀 네비 UI 세팅
kangyuri1114 a779c8e
[feat] 바텀 네비 constraint 수정
kangyuri1114 18b23e2
[feat] 바텀 네비 아이템 클릭 리스너 함수 추가
kangyuri1114 334cac4
Merge branch 'develop' into feat/set-bottom-navigation
kangyuri1114 0dc0340
[feat] 현 메인 액티비티 명을 cefeteriaActivity로 변경
kangyuri1114 1a7ac30
[feat] 현 메인 액티비티 명을 cefeteriaActivity로 변경
kangyuri1114 cbaa8aa
[feat] Mypage, Cafeteria Fragment 로 전환 후 MainActivity에 있어야 하는 로직 옮기기.…
kangyuri1114 30d644e
[chore] 주석 추가 및 불필요 코드 삭제
kangyuri1114 a494fe9
[chore] Mypage, Cafeteria Fragment를 MainActivity ViewPager 로 넣기는 성공 했…
kangyuri1114 f514999
[feat] CalendarViewModel 로직을 MainViewModel로 옮김
kangyuri1114 12a89d5
[chore] 불필요한 코드 삭제
kangyuri1114 f803c08
[fix] 이전, 다음 주차 이동 버튼 클릭 시 앱터짐 이슈 해결 (데이터바인딩을 뷰바인딩으로)
kangyuri1114 7a5894c
[chore] 불필요한 코드 삭제
kangyuri1114 8bbea17
[feat] 마이페이지 toolbar 추가
kangyuri1114 6d534b9
[feat] map 프래그먼트 컴포즈 뷰 띄우기 성공 및 임시로 주석처리 진행
kangyuri1114 1ae1bd1
Merge branch 'develop' into feat/set-bottom-navigation
kangyuri1114 bda5973
release 2.1.7 (#278)
kangyuri1114 b766b9e
[Chore] Change delete/modify/report modal (#248)
HI-JIN2 39c8996
feat: splash 기존 이미지로 변경 및 스플래쉬 실행 시간 2초로 복구 (#281)
kangyuri1114 c5879dd
feat: splash 배경 색 변경 (#282)
kangyuri1114 a1c32f7
Merge branch 'develop' into feat/set-bottom-navigation
kangyuri1114 7f69207
feat: BottomNavigation 에서 viewPager로 화면 전환하던 방식을 jetpack navigation 방…
kangyuri1114 af06c6b
Merge branch 'develop' into feat/set-bottom-navigation
kangyuri1114 15f58b9
Merge branch 'develop' into feat/set-bottom-navigation
kangyuri1114 c491207
feat: menu 정보 liveData -> flow 수정
kangyuri1114 3eda238
feat: uistate 세팅
kangyuri1114 ef8fd0f
feat: 로그 삭제
kangyuri1114 8706b6b
feat: 디버깅 로그 추가
kangyuri1114 eac5ef9
Merge branch 'develop' into feat/fix-bottom-navi-error
kangyuri1114 9556ead
[feat] 코드 정리
kangyuri1114 465b3a9
[feat] menuViewModel에 menuService, mealService 직접 주입하던 방식을 hilt로 주입하도…
kangyuri1114 aa0fe84
[feat] 다른 날짜 클릭 시 프래그먼트 내에서 각 식당의 메뉴 정보 중복 문제 해결
kangyuri1114 34c7b10
[feat] 불필요 import 삭제, MenuViewModelFactory.kt 삭제
kangyuri1114 891e875
[feat] NetworkModule, ServiceModule 분리
kangyuri1114 1409917
[feat] 코드 정리
kangyuri1114 9145dfc
[feat] 주석 코드 삭제
kangyuri1114 a09df12
[feat] 바텀 내비 지도 관련 코드 주석 처리
kangyuri1114 cfb86fb
[feat] CalendarViewModel.kt 삭제
kangyuri1114 e50e7e9
[feat] repackaging
kangyuri1114 b8f7040
[feat] merge develop
kangyuri1114 ae46236
[feat] 불필요 코드 삭제
kangyuri1114 4018cb6
[feat] string 추출
kangyuri1114 9d4f32f
[feat] viewmodel 선언 형식 통일
kangyuri1114 4bed0da
[feat] 로그아웃 후 로그인 화면으로 이동 코드 추가 및 log -> timber
kangyuri1114 c17656f
[feat] 마이페이지 이미지 버튼 삭제
kangyuri1114 6b12449
[feat] 불필요 이미지 삭제
kangyuri1114 d8170e9
[feat] 패키징 정리, 불필요 파일 삭제
kangyuri1114 fab649e
[feat] 연타 방지용 setOnSingleItemSelectedListener 추가
kangyuri1114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package com.eatssu.android.di | ||
|
|
||
| import com.eatssu.android.data.service.MealService | ||
| import com.eatssu.android.data.service.MenuService | ||
| import com.eatssu.android.data.service.ReportService | ||
| import com.eatssu.android.data.service.ReviewService | ||
| import com.eatssu.android.data.service.UserService | ||
| import dagger.Module | ||
| import dagger.Provides | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.components.SingletonComponent | ||
| import retrofit2.Retrofit | ||
| import javax.inject.Singleton | ||
|
|
||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| object ServiceModule { | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| fun provideUserService(retrofit: Retrofit): UserService { | ||
| return retrofit.create(UserService::class.java) | ||
| } | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| fun provideReportService(retrofit: Retrofit): ReportService { | ||
| return retrofit.create(ReportService::class.java) | ||
| } | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| fun provideReviewService(retrofit: Retrofit): ReviewService { | ||
| return retrofit.create(ReviewService::class.java) | ||
| } | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| fun provideMealService(retrofit: Retrofit): MealService { | ||
| return retrofit.create(MealService::class.java) | ||
| } | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| fun provideMenuService(retrofit: Retrofit): MenuService { | ||
| return retrofit.create(MenuService::class.java) | ||
| } | ||
| } | ||
188 changes: 188 additions & 0 deletions
188
app/src/main/java/com/eatssu/android/presentation/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| package com.eatssu.android.presentation | ||
|
|
||
| import android.Manifest | ||
| import android.annotation.SuppressLint | ||
| import android.content.pm.PackageManager | ||
| import android.os.Build | ||
| import android.os.Bundle | ||
| import android.os.SystemClock | ||
| import android.view.MenuItem | ||
| import android.view.View | ||
| import androidx.activity.viewModels | ||
| import androidx.annotation.RequiresApi | ||
| import androidx.core.app.ActivityCompat | ||
| import androidx.core.content.ContextCompat | ||
| import androidx.lifecycle.lifecycleScope | ||
| import androidx.navigation.fragment.NavHostFragment | ||
| import com.eatssu.android.R | ||
| import com.eatssu.android.databinding.ActivityMainBinding | ||
| import com.eatssu.android.presentation.base.BaseActivity | ||
| import com.eatssu.android.presentation.login.LoginActivity | ||
| import com.eatssu.android.presentation.mypage.MyPageViewModel | ||
| import com.eatssu.android.presentation.mypage.usernamechange.UserNameChangeActivity | ||
| import com.eatssu.android.presentation.util.showToast | ||
| import com.eatssu.android.presentation.util.startActivity | ||
| import com.google.android.material.bottomnavigation.BottomNavigationView | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import kotlinx.coroutines.flow.collectLatest | ||
| import kotlinx.coroutines.launch | ||
| import timber.log.Timber | ||
| import java.text.SimpleDateFormat | ||
| import java.util.Locale | ||
|
|
||
| @AndroidEntryPoint | ||
| class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::inflate){ | ||
|
|
||
| private val mainViewModel: MainViewModel by viewModels() | ||
| private val myPageViewModel: MyPageViewModel by viewModels() | ||
|
|
||
| @RequiresApi(Build.VERSION_CODES.O) | ||
| @SuppressLint("SuspiciousIndentation") | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
|
|
||
| setupNoToolbar() | ||
| setNavigation() | ||
|
|
||
| checkAlarmPermission() | ||
| checkNicknameIsNull() | ||
|
|
||
| collectLogoutState() | ||
| } | ||
|
|
||
| private fun setNavigation() { | ||
| val navHostFragment = supportFragmentManager | ||
| .findFragmentById(R.id.nav_host_fragment) as NavHostFragment | ||
| val navController = navHostFragment.navController | ||
|
|
||
| binding.bottomNaviBar.setOnSingleItemSelectedListener { item -> | ||
| when (item.itemId) { | ||
| R.id.cafeteria_menu -> { | ||
| navController.navigate(R.id.homeFragment) | ||
| true | ||
| } | ||
|
|
||
| // R.id.map_menu -> { | ||
| // navController.navigate(R.id.mapFragment) | ||
| // true | ||
| // } | ||
|
|
||
| R.id.mypage_menu -> { | ||
| navController.navigate(R.id.myPageFragment) | ||
| true | ||
| } | ||
|
|
||
| else -> { | ||
| false | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // set UI -- | ||
| private fun setupNoToolbar() { | ||
| // 툴바 사용하지 않도록 설정 | ||
| toolbar.let { | ||
| toolbar.visibility = View.GONE | ||
| toolbarTitle.visibility = View.GONE | ||
| setSupportActionBar(it) | ||
| supportActionBar?.setDisplayHomeAsUpEnabled(false) | ||
| supportActionBar?.setDisplayShowTitleEnabled(false) | ||
| } | ||
| } | ||
|
|
||
| // Permission -- | ||
| // 권한 요청 결과 처리 | ||
| override fun onRequestPermissionsResult( | ||
| requestCode: Int, | ||
| permissions: Array<out String>, | ||
| grantResults: IntArray | ||
| ) { | ||
| super.onRequestPermissionsResult(requestCode, permissions, grantResults) | ||
|
|
||
| val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()) | ||
|
|
||
| if (requestCode == 1000) { | ||
| if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | ||
| // 권한이 승인됨 | ||
| showToast("EAT-SSU 알림 수신을 동의하였습니다.") | ||
| myPageViewModel.setNotificationOn() //바로 알림 받도록 설정 | ||
| } else { | ||
| // 권한이 거부됨 | ||
| showToast("EAT-SSU 알림 수신을 거부하였습니다.\n$dateFormat") | ||
| myPageViewModel.setNotificationOff() //바로 알림 받도록 설정 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // 알림 퍼미션 있는지 자가 진단 | ||
| private fun checkAlarmPermission() { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
| if (ContextCompat.checkSelfPermission( | ||
| this, | ||
| Manifest.permission.POST_NOTIFICATIONS | ||
| ) != PackageManager.PERMISSION_GRANTED | ||
| ) { | ||
| // 권한이 없다면 요청 | ||
| ActivityCompat.requestPermissions( | ||
| this, | ||
| arrayOf(Manifest.permission.POST_NOTIFICATIONS), | ||
| 1000 | ||
| ) | ||
| } else { | ||
| // 권한이 이미 있어 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // CollectState -- | ||
| private fun checkNicknameIsNull() { | ||
| Timber.d("관찰 시작") | ||
| mainViewModel.checkNameNull() | ||
|
|
||
| lifecycleScope.launch { | ||
| mainViewModel.uiState.collectLatest { | ||
| if (it.isNicknameNull) { | ||
| //닉네임이 null일 때는 닉네임 설정을 안하면 서비스를 못쓰게 막아야함 | ||
| intent.putExtra("force", true) | ||
| startActivity<UserNameChangeActivity>() | ||
| showToast(it.toastMessage) | ||
| } else { | ||
| showToast(it.toastMessage) //Todo 이게 누구님 반갑습니다. 인데 두번 뜸 | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // 로그아웃 처리 | ||
| private fun collectLogoutState() { | ||
| lifecycleScope.launch { | ||
| mainViewModel.uiState.collectLatest { state -> | ||
| if (state.isLoggedOut) { | ||
| showToast(state.toastMessage) | ||
| startActivity<LoginActivity>() | ||
| finishAffinity() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // 아래 함수를 View 에서는 사용이 어려워 util 로 빼지 않음 | ||
| private fun BottomNavigationView.setOnSingleItemSelectedListener( | ||
| minInterval: Long = 2000L, | ||
| onSingleItemSelected: (item: MenuItem) -> Boolean | ||
| ) { | ||
| var lastClickTime = 0L | ||
|
|
||
| setOnItemSelectedListener { item -> | ||
| val currentClickTime = SystemClock.uptimeMillis() | ||
| if (currentClickTime - lastClickTime > minInterval) { | ||
| lastClickTime = currentClickTime | ||
| onSingleItemSelected(item) | ||
| } else { | ||
| false // 너무 빠른 클릭 무시 | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+170
to
+187
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호 이거 baseActivity에 할 줄 알았는데, mainActivity에 하셨군요!👍 근데 이제 compose로 짜면 base activity도 의미 없을 것 같아요 그죠? |
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아아 xxxService만 따로 뺀거군요. 뭔가 하고 한참 봤네요