Skip to content

Commit

Permalink
strings.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
gunyu1019 committed May 11, 2022
1 parent e15596b commit 506a903
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 15 deletions.
35 changes: 20 additions & 15 deletions app/src/main/java/kr/yhs/traffic/ui/pages/StationInfoPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.rotary.onRotaryScrollEvent
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
Expand Down Expand Up @@ -146,6 +147,7 @@ fun StationRoute(
timeLoop: Int
) {
var backgroundColor = BusColor.Default
val context = LocalContext.current
for (busColor in BusColor.values()) {
if (busInfo.type == busColor.typeCode) {
backgroundColor = busColor
Expand Down Expand Up @@ -173,44 +175,47 @@ fun StationRoute(
if (busInfo.isEnd != true && busInfo.isWait != true && busInfo.arrivalInfo.isNotEmpty()) {
for (arrivalInfo in busInfo.arrivalInfo) {
var timeMillis by remember { mutableStateOf(arrivalInfo.time) }
var time by remember { mutableStateOf("0초") }
var time by remember { mutableStateOf(context.getString(R.string.timestamp_second, 0)) }

if (timeMillis == -1 || arrivalInfo.prevCount == null)
continue
time = when {
timeMillis / 60 < 1 -> "${timeMillis}"
timeMillis / 3600 < 1 && (timeMillis % 60 == 0 || (busInfo.type in 1200..1299) || (busInfo.type in 2100..2199)) -> "${timeMillis / 60}"
timeMillis / 3600 < 1 && (busInfo.type in 1100..1199 || busInfo.type in 1300..1399) -> "${timeMillis / 60}${timeMillis % 60}"
timeMillis / 216000 < 1 -> "${timeMillis / 3600}시간 ${timeMillis % 3600 / 60}"
else -> "${timeMillis}"
timeMillis / 60 < 1 -> context.getString(R.string.timestamp_second, timeMillis)
timeMillis / 3600 < 1 && (timeMillis % 60 == 0 || (busInfo.type in 1200..1299) || (busInfo.type in 2100..2199)) -> context.getString(R.string.timestamp_minute, timeMillis / 60)
timeMillis / 3600 < 1 && (busInfo.type in 1100..1199 || busInfo.type in 1300..1399) -> context.getString(R.string.timestamp_minute_second, timeMillis / 60, timeMillis % 60)
timeMillis / 216000 < 1 -> context.getString(R.string.timestamp_hour_minute, timeMillis / 3600, timeMillis % 3600 / 60)
else -> context.getString(R.string.timestamp_second, timeMillis)
}
timeMillis = arrivalInfo.time - (timeLoop / 1000)

var response: String? = null
if (arrivalInfo.prevCount == 0 && timeMillis <= 180 || timeMillis <= 60) {
if (arrivalInfo.seat != null)
response = "${arrivalInfo.seat}"
ArrivalText("곧 도착", response)
response = context.getString(R.string.arrival_text_subtext_seat, arrivalInfo.seat)
ArrivalText(context.getString(R.string.arrival_text_soon), response)
}
else {
response = "${arrivalInfo.prevCount}번째 전"
response = context.getString(R.string.arrival_text_subtext_prev_count, arrivalInfo.prevCount)
if (arrivalInfo.seat != null)
response = "${arrivalInfo.prevCount}번째 전, ${arrivalInfo.seat}"
response = context.getString(R.string.arrival_text_subtext_prev_count_with_seat, arrivalInfo.prevCount, arrivalInfo.seat)
if (arrivalInfo.congestion != null) {
val congestionList = listOf(
"여유", "보통", "혼잡"
context.getString(R.string.congestion_leisurely),
context.getString(R.string.congestion_normal),
context.getString(R.string.congestion_crowded),
context.getString(R.string.congestion_very_crowded)
)
response = "${arrivalInfo.prevCount}번째 전, ${congestionList[arrivalInfo.congestion - 1]}"
response = context.getString(R.string.arrival_text_subtext_prev_count_with_congestion, arrivalInfo.prevCount, congestionList[arrivalInfo.congestion - 1])
}
ArrivalText(time, response)
}
}
} else if (busInfo.isEnd == true) {
ArrivalText("운행 종료")
ArrivalText(context.getString(R.string.arrival_text_closed))
} else if (busInfo.isWait == true) {
ArrivalText("출발 대기")
ArrivalText(context.getString(R.string.arrival_text_wait))
} else {
ArrivalText("정보 없음")
ArrivalText(context.getString(R.string.arrival_text_unknown))
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,24 @@
<string name="station_not_found">No bus stop information found.</string>
<string name="timeout">Failed to bring information.</string>
<string name="result_not_found">Not Found</string>

<string name="timestamp_second">%ds</string>
<string name="timestamp_minute_second">%dm %ds</string>
<string name="timestamp_minute">%dm</string>
<string name="timestamp_hour_minute">%dh %dm</string>

<string name="arrival_text_soon">Arriving Soon</string>
<string name="arrival_text_subtext_seat">%d seats</string>
<string name="arrival_text_subtext_prev_count">%d ago</string>
<string name="arrival_text_subtext_prev_count_with_seat">%d ago, %d seats</string>
<string name="arrival_text_subtext_prev_count_with_congestion">%d ago, %s</string>

<string name="congestion_leisurely">Leisurely</string>
<string name="congestion_normal">Normal</string>
<string name="congestion_crowded">Crowded</string>
<string name="congestion_very_crowded">Very Crowded</string>

<string name="arrival_text_closed">End of Service</string>
<string name="arrival_text_wait">Wait for Departure</string>
<string name="arrival_text_unknown">Unknown</string>
</resources>
20 changes: 20 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,24 @@
<string name="station_not_found">정류장을 불러올 수 없습니다.</string>
<string name="timeout">정보를 불러오는데 실패했습니다.</string>
<string name="result_not_found">결과 없음</string>

<string name="timestamp_second">%d초</string>
<string name="timestamp_minute_second">%d분 %d초</string>
<string name="timestamp_minute">%d분</string>
<string name="timestamp_hour_minute">%d시간 %d분</string>

<string name="arrival_text_soon">곧 도착</string>
<string name="arrival_text_subtext_seat">%d석</string>
<string name="arrival_text_subtext_prev_count">%d번째 전</string>
<string name="arrival_text_subtext_prev_count_with_seat">%d번째 전, %d석</string>
<string name="arrival_text_subtext_prev_count_with_congestion">%d번째 전, %s</string>

<string name="congestion_leisurely">여유</string>
<string name="congestion_normal">보통</string>
<string name="congestion_crowded">혼잡</string>
<string name="congestion_very_crowded">매우 혼잡</string>

<string name="arrival_text_closed">운행 종료</string>
<string name="arrival_text_wait">출발 대기</string>
<string name="arrival_text_unknown">정보 없음</string>
</resources>

0 comments on commit 506a903

Please sign in to comment.