Skip to content

Commit 49b57b0

Browse files
authored
Merge pull request #204 from depromeet/feat/alarm-fix#177
[#203] 현위치 버튼 위치 수정 & 일부 알람 로직 개선
2 parents c0ab8ac + 20bc649 commit 49b57b0

File tree

22 files changed

+408
-196
lines changed

22 files changed

+408
-196
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ android {
3939
applicationId = "com.depromeet.team6"
4040
minSdk = 26
4141
targetSdk = 35
42-
versionCode = 14
43-
versionName = "1.3.0"
42+
versionCode = 16
43+
versionName = "1.3.11"
4444

4545
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
4646
buildConfigField("String", "KAKAO_NATIVE_APP_KEY", properties["kakao.native.app.key"].toString())

app/src/main/java/com/depromeet/team6/data/background/LockService.kt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import com.google.android.gms.location.LocationServices
3434
import dagger.hilt.android.AndroidEntryPoint
3535
import kotlinx.coroutines.CoroutineScope
3636
import kotlinx.coroutines.Dispatchers
37+
import kotlinx.coroutines.cancel
3738
import kotlinx.coroutines.delay
3839
import kotlinx.coroutines.launch
3940
import kotlinx.coroutines.withContext
@@ -62,6 +63,7 @@ class LockService : Service() {
6263
private val notificationManager by lazy {
6364
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
6465
}
66+
private val timerScope = CoroutineScope(Dispatchers.Default)
6567

6668
private fun playAlarm() {
6769
val isSound = userInfoRepositoryImpl.getAlarmSound()
@@ -191,11 +193,6 @@ class LockService : Service() {
191193
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
192194
Log.d("LockService", "onStartCommand 호출됨")
193195

194-
if (intent?.action == ACTION_STOP_ALARM_SOUND) {
195-
stopAlarm()
196-
return START_STICKY
197-
}
198-
199196
startLockReceiver()
200197
wakeLockAcquire()
201198

@@ -207,7 +204,10 @@ class LockService : Service() {
207204

208205
lockScreenNavigator.navigateToLockScreen(applicationContext, taxiCost)
209206
}
207+
}
210208

209+
// 2분 후 알람 종료
210+
timerScope.launch {
211211
delay(ALARM_DURATION_MS)
212212
withContext(Dispatchers.Main) {
213213
AmplitudeUtils.trackEventWithProperties(
@@ -227,10 +227,16 @@ class LockService : Service() {
227227
)
228228

229229
val notification = NotificationCompat.Builder(this@LockService, ATCHA_SERVICE_CHANNEL_ID)
230+
.setContentTitle(
231+
ContextCompat.getString(
232+
this@LockService,
233+
R.string.notification_alarm_timeout_title
234+
)
235+
)
230236
.setContentText(
231237
ContextCompat.getString(
232238
this@LockService,
233-
R.string.notification_alarm_timeout
239+
R.string.notification_alarm_timeout_body
234240
)
235241
)
236242
.setSmallIcon(R.drawable.ic_app_logo_foreground)
@@ -254,6 +260,7 @@ class LockService : Service() {
254260
stopAlarm()
255261
vibrationTimer?.cancel()
256262
vibrationTimer = null
263+
timerScope.cancel()
257264
super.onDestroy()
258265
}
259266

@@ -283,8 +290,6 @@ class LockService : Service() {
283290
}
284291
}
285292
companion object {
286-
const val ACTION_STOP_ALARM_SOUND = "com.depromeet.team6.STOP_ALARM_SOUND"
287-
288293
const val ALARM_NOTIFICATION_ID = 1
289294
const val ALARM_NOTIFICATION_TIMEOUT_ID = 2
290295

app/src/main/java/com/depromeet/team6/domain/usecase/GetCourseSearchResultsUseCase.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class GetCourseSearchResultsUseCase @Inject constructor(
3838
"REQ_001" -> TODO()
3939
"REQ_002" -> TODO()
4040
"TOK_002" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_LOGIN_TOKEN_EXPIRED, route = Route.Login)
41-
"USR_002" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_INVALID_LOCATION, route = Route.Home)
42-
"LOC_003" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_INVALID_LOCATION, route = Route.Home)
43-
"LOC_004" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_INVALID_LOCATION, route = Route.Home)
41+
"USR_002" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_INVALID_LOCATION, route = Route.Back)
42+
"LOC_003" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_INVALID_LOCATION, route = Route.Back)
43+
"LOC_004" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_INVALID_LOCATION, route = Route.Back)
4444
"TRS_001" -> TODO()
45-
"TRS_011" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_SHORT_DISTANCE, route = Route.Home)
46-
"TRS_012" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_OUT_OF_SERVICE_REGION, route = Route.Home)
45+
"TRS_011" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_SHORT_DISTANCE, route = Route.Back)
46+
"TRS_012" -> ErrorControlFailureException.NavigateAndShowToastException(toastMessage = API_ERROR_OUT_OF_SERVICE_REGION, route = Route.Back)
4747
"INTERNAL_SERVER_ERROR" -> ErrorControlFailureException.ShowToastException(toastMessage = API_ERROR_NETWORK_FAILURE)
4848
else -> ErrorControlFailureException.ShowToastException(API_ERROR_NETWORK_FAILURE)
4949
}

app/src/main/java/com/depromeet/team6/presentation/ui/coursesearch/CourseSearchScreen.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.Column
88
import androidx.compose.foundation.layout.PaddingValues
99
import androidx.compose.foundation.layout.fillMaxSize
1010
import androidx.compose.foundation.layout.padding
11-
import androidx.compose.material.CircularProgressIndicator
1211
import androidx.compose.runtime.Composable
1312
import androidx.compose.runtime.DisposableEffect
1413
import androidx.compose.runtime.LaunchedEffect
@@ -26,6 +25,7 @@ import androidx.lifecycle.compose.LocalLifecycleOwner
2625
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2726
import com.depromeet.team6.R
2827
import com.depromeet.team6.domain.model.course.LegInfo
28+
import com.depromeet.team6.presentation.ui.common.view.AtChaLoadingView
2929
import com.depromeet.team6.presentation.ui.coursesearch.component.CourseAppBar
3030
import com.depromeet.team6.presentation.ui.coursesearch.component.DestinationSearchBar
3131
import com.depromeet.team6.presentation.ui.coursesearch.component.TransportTabMenu
@@ -54,6 +54,7 @@ fun CourseSearchRoute(
5454
navigateToHome: () -> Unit,
5555
navigateToHomeAfterAlarmRegister: () -> Unit,
5656
navigateToLogin: () -> Unit,
57+
popBackStack: () -> Unit,
5758
fromLockScreen: Boolean = false,
5859
viewModel: CourseSearchViewModel = hiltViewModel()
5960
) {
@@ -104,6 +105,10 @@ fun CourseSearchRoute(
104105
navigateToHome()
105106
}
106107

108+
is ApiErrorSideEffect.NavigateToBackSideEffect -> {
109+
popBackStack()
110+
}
111+
107112
is ApiErrorSideEffect.NavigateToLoginSideEffect -> {
108113
navigateToLogin()
109114
}
@@ -134,7 +139,7 @@ fun CourseSearchRoute(
134139
.padding(padding)
135140
)
136141
Box(modifier = Modifier.fillMaxSize()) {
137-
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
142+
AtChaLoadingView()
138143
}
139144
}
140145

app/src/main/java/com/depromeet/team6/presentation/ui/coursesearch/component/SearchResultEmpty.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import com.depromeet.team6.ui.theme.defaultTeam6Typography
2323

2424
@Composable
2525
fun SearchResultEmpty(
26-
modifier: Modifier = Modifier
26+
modifier: Modifier = Modifier,
27+
isApiError: Boolean = false
2728
) {
2829
Box(
2930
modifier = modifier

app/src/main/java/com/depromeet/team6/presentation/ui/coursesearch/component/TransportTabMenu.kt

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import com.depromeet.team6.domain.model.course.LegInfo
2121
import com.depromeet.team6.presentation.ui.itinerary.LegInfoDummyProvider
2222
import com.depromeet.team6.ui.theme.defaultTeam6Colors
2323
import kotlinx.coroutines.launch
24+
import java.time.LocalTime
25+
import java.time.ZoneId
2426

2527
@Composable
2628
fun TransportTabMenu(
@@ -70,25 +72,34 @@ fun TransportTabMenu(
7072
} else {
7173
availableCourses.filter { it.filterCategory == page }
7274
}
73-
74-
if (resultItems.isEmpty() && isLoaded) {
75-
SearchResultEmpty(
76-
modifier = Modifier.padding(top = 10.dp)
77-
)
78-
} else {
79-
LastTransportInfoList(
80-
listData = resultItems,
81-
onItemClick = onItemClick,
82-
courseInfoToggleClick = courseInfoToggleClick,
83-
onRegisterAlarmBtnClick = { routeId ->
84-
onRegisterAlarmBtnClick(routeId)
85-
}
86-
)
75+
if (isLoaded) {
76+
if (resultItems.isEmpty() || isMidNight()) {
77+
SearchResultEmpty(
78+
modifier = Modifier.padding(top = 10.dp)
79+
)
80+
} else {
81+
LastTransportInfoList(
82+
listData = resultItems,
83+
onItemClick = onItemClick,
84+
courseInfoToggleClick = courseInfoToggleClick,
85+
onRegisterAlarmBtnClick = { routeId ->
86+
onRegisterAlarmBtnClick(routeId)
87+
}
88+
)
89+
}
8790
}
8891
}
8992
}
9093
}
9194

95+
private fun isMidNight(): Boolean {
96+
val currentTime = LocalTime.now(ZoneId.systemDefault())
97+
val midnight = LocalTime.MIDNIGHT // 00:00:00
98+
val fiveAM = LocalTime.of(5, 0, 0) // 05:00:00
99+
100+
return !currentTime.isBefore(midnight) && currentTime.isBefore(fiveAM)
101+
}
102+
92103
@Preview
93104
@Composable
94105
fun PreviewTabMenu(

app/src/main/java/com/depromeet/team6/presentation/ui/coursesearch/navigation/CourseSearchNavigation.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ fun NavGraphBuilder.courseSearchNavGraph(
2222
navigateToHome: () -> Unit,
2323
navigateToHomeAfterAlarmRegister: () -> Unit,
2424
navigateToLogin: () -> Unit,
25-
navigateToItinerary: (String, String, String) -> Unit
25+
navigateToItinerary: (String, String, String) -> Unit,
26+
popBackStack: () -> Unit
2627
) {
2728
composable(
2829
route = "${CourseSearchRoute.ROUTE}/{${CourseSearchRoute.DEPARTURE_POINT}}/{${CourseSearchRoute.DESTINATION_POINT}}",
@@ -45,6 +46,7 @@ fun NavGraphBuilder.courseSearchNavGraph(
4546
navigateToHome = navigateToHome,
4647
navigateToHomeAfterAlarmRegister = navigateToHomeAfterAlarmRegister,
4748
navigateToLogin = navigateToLogin,
49+
popBackStack = popBackStack,
4850
departurePoint = departurePoint,
4951
destinationPoint = destinationPoint,
5052
fromLockScreen = fromLockScreen

app/src/main/java/com/depromeet/team6/presentation/ui/home/HomeContract.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class HomeContract {
2626
val showSpeechBubble: Boolean = true,
2727
val locationAddress: String = "",
2828
val currentLocation: LatLng = LatLng(DEFAULT_LAT, DEFAULT_LNG),
29+
val isMapFocused: Boolean = true,
2930
// 알림 등록 후 경로 표시
3031
val itineraryInfo: CourseInfo? = null,
3132
val courseDataLoadState: LoadState = LoadState.Idle,

0 commit comments

Comments
 (0)