Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class RunActivity : BindingActivity<ActivityRunBinding>(R.layout.activity_run),
getCurrentLocation()
showRecord()
backButton()
setUpPauseResume()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate RunActivity.kt =="
fd -a 'RunActivity\.kt$' . || true

echo "== file outline =="
if [ -f app/src/main/java/com/runnect/runnect/presentation/run/RunActivity.kt ]; then
  ast-grep outline app/src/main/java/com/runnect/runnect/presentation/run/RunActivity.kt --view expanded || true
  echo "== relevant lines =="
  sed -n '1,220p' app/src/main/java/com/runnect/runnect/presentation/run/RunActivity.kt | nl -ba -v1
fi

echo "== search RunViewModel isPaused/updatePauseResumeUI == "
rg -n "isPaused|updatePauseResumeUI|setUpPauseResume|ViewModel|onResume|onPause|onStop" app/src/main/java/com/runnect/runnect/presentation/run -S || true

Repository: Runnect/Runnect-Android

Length of output: 3001


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== RunActivity.kt relevant sections =="
sed -n '80,175p' app/src/main/java/com/runnect/runnect/presentation/run/RunActivity.kt

echo "== RunViewModel references =="
rg -n "class RunViewModel|RunViewModel|isPaused|updatePauseResumeUI|setUpPauseResume" app/src/main/java/com/runnect/runnect/presentation/run -S

echo "== TimerService pause references =="
rg -n "pause|resume|isPaused|broadcast|Pause|Resume" app/src/main/java/com/runnect/runnect -S || true

Repository: Runnect/Runnect-Android

Length of output: 8933


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== RunViewModel.kt =="
sed -n '1,80p' app/src/main/java/com/runnect/runnect/presentation/run/RunViewModel.kt

echo "== timerService pause/resume interaction in TimerService and TimerHandler =="
rg -n "mHandler|mTimerTask|timerService|pause|resume|stop|start" app/src/main/java/com/runnect/runnect/presentation/run/TimerService.kt -S
sed -n '1,160p' app/src/main/java/com/runnect/runnect/presentation/run/TimerService.kt

Repository: Runnect/Runnect-Android

Length of output: 6404


Render the retained pause state when the activity is recreated.

RunViewModel.isPaused survives configuration changes, but updatePauseResumeUI() only runs from the pause/resume button callback. After rotation during a pause, the recreated UI shows the running icon while the timer service remains paused.

Read isPaused in onCreate() from the retained ViewModel value and call updatePauseResumeUI() for that value before setting up the button listener.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/com/runnect/runnect/presentation/run/RunActivity.kt` at
line 100, Update RunActivity.onCreate() to read the retained
RunViewModel.isPaused value and call updatePauseResumeUI() with it before
setUpPauseResume(), ensuring the recreated activity displays the correct
pause/resume state.


val runCourseData: CourseData? = intent.getParcelableExtra(EXTRA_COUNTDOWN_TO_RUN)
val targetDistanceM = runCourseData?.distance?.let { (it * 1000f).roundToInt() }
Expand Down Expand Up @@ -133,6 +134,30 @@ class RunActivity : BindingActivity<ActivityRunBinding>(R.layout.activity_run),
stopService(serviceIntent) //서비스 객체 제거
}

private fun setUpPauseResume() {
binding.btnRunPauseResume.setOnClickListener {
val isPaused = viewModel.isPaused.value ?: false
if (isPaused) {
timerService?.resumeTimer()
} else {
timerService?.pauseTimer()
}
viewModel.isPaused.value = !isPaused
updatePauseResumeUI(!isPaused)
Comment on lines +137 to +146

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate files =="
fd -a 'RunActivity\.kt$|TimerService\.kt$' . | sed 's#^\./##'

echo "== RunActivity outline/sections =="
RUNACTIVITY="$(fd 'RunActivity\.kt$' . | head -n1 || true)"
if [ -n "${RUNACTIVITY:-}" ]; then
  echo "--- $RUNACTIVITY lines 1-230 ---"
  sed -n '1,230p' "$RUNACTIVITY" | nl -ba
fi

echo "== TimerService outline/sections =="
TIMER="$(fd 'TimerService\.kt$' . | head -n1 || true)"
if [ -n "${TIMER:-}" ]; then
  echo "--- $TIMER lines 1-260 ---"
  sed -n '1,260p' "$TIMER" | nl -ba
fi

echo "== references to timerService/isPaused/pauseResume/updatePauseResumeUI =="
rg -n "timerService|isPaused|pauseResume|updatePauseResumeUI|onServiceConnected|bindService|UnbindService|btnRunPauseResume" app/src/main/java || true

Repository: Runnect/Runnect-Android

Length of output: 628


🏁 Script executed:

#!/bin/bash
set -euo pipefail

RUNACTIVITY="$(fd 'RunActivity\.kt$' . | grep 'app/src/main/java/com/runnect/runnect/presentation/run/RunActivity.kt' || true)"
TIMER="$(fd 'TimerService\.kt$' . | grep 'app/src/main/java/com/runnect/runnect/presentation/run/TimerService.kt' || true)"

echo "== RunActivity relevant sections =="
sed -n '1,240p' "${RUNACTIVITY:-/dev/null}"
echo
echo "== TimerService relevant sections =="
sed -n '1,280p' "${TIMER:-/dev/null}"

echo
echo "== references =="
rg -n "timerService|isPaused|setUpPauseResume|updatePauseResumeUI|onServiceConnected|bindService|bindServiceAsync|UnbindService|btnRunPauseResume|pauseTimer|resumeTimer" app/src/main/java || true

echo
echo "== Kotlin safe-call behavior probe =="
node - <<'JS'
let timerServiceCalled = false;
class TimerService {
  pauseTimer() {
    timerServiceCalled = true;
    console.log("pauseTimer called");
  }
  resumeTimer() {
    console.log("resumeTimer called");
  }
}
let timerService = null;
let viewModelIsPaused = false;
// Kotlin safe-call null behavior: if receiver is null, expression returns null and body is skipped.
try {
  if (timerService != null) {
    timerService.pauseTimer();
  }
} catch (e) {
  console.error(e);
}
viewModelIsPaused = !viewModelIsPaused;
console.log({timerServiceCalled, viewModelIsPaused});

timerService = new TimerService();
if (timerService != null) {
  timerService.resumeTimer();
}
console.log({timerServiceCalled});
JS

Repository: Runnect/Runnect-Android

Length of output: 17308


Return before updating pause state if timerService is not bound.

timerService is set in onServiceConnected, but the pause button is available immediately. A tap before binding calls resumeTimer() when the service has not bound, then sets isPaused to true. The next tap calls startTimer() while the existing timer is still active, creating a second schedule and doubling elapsed-time broadcasts.

Check timerService before changing either state or UI.

Proposed fix
 private fun setUpPauseResume() {
     binding.btnRunPauseResume.setOnClickListener {
+        val service = timerService ?: return@setOnClickListener
         val isPaused = viewModel.isPaused.value ?: false
         if (isPaused) {
-            timerService?.resumeTimer()
+            service.resumeTimer()
         } else {
-            timerService?.pauseTimer()
+            service.pauseTimer()
         }
         viewModel.isPaused.value = !isPaused
         updatePauseResumeUI(!isPaused)
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private fun setUpPauseResume() {
binding.btnRunPauseResume.setOnClickListener {
val isPaused = viewModel.isPaused.value ?: false
if (isPaused) {
timerService?.resumeTimer()
} else {
timerService?.pauseTimer()
}
viewModel.isPaused.value = !isPaused
updatePauseResumeUI(!isPaused)
private fun setUpPauseResume() {
binding.btnRunPauseResume.setOnClickListener {
val service = timerService ?: return@setOnClickListener
val isPaused = viewModel.isPaused.value ?: false
if (isPaused) {
service.resumeTimer()
} else {
service.pauseTimer()
}
viewModel.isPaused.value = !isPaused
updatePauseResumeUI(!isPaused)
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/com/runnect/runnect/presentation/run/RunActivity.kt` around
lines 137 - 146, In setUpPauseResume, return immediately from the click listener
when timerService is null, before invoking pause/resume or updating
viewModel.isPaused and the UI. Only perform the existing toggle and
updatePauseResumeUI flow after confirming the service is bound.

}
}

private fun updatePauseResumeUI(isPaused: Boolean) {
binding.btnRunPauseResume.apply {
setImageResource(if (isPaused) R.drawable.ic_run_resume else R.drawable.ic_run_pause)
contentDescription = getString(
if (isPaused) R.string.run_description_resume else R.string.run_description_pause
)
}
binding.btnRunStop.visibility = if (isPaused) View.VISIBLE else View.GONE
binding.tvPausedLabel.visibility = if (isPaused) View.VISIBLE else View.GONE
}

override fun onStart() {
super.onStart()
// Timer 결과값을 받기 위해 브로드캐스트 리시버 등록
Expand Down Expand Up @@ -336,7 +361,7 @@ class RunActivity : BindingActivity<ActivityRunBinding>(R.layout.activity_run),
}

private fun showRecord() {
binding.btnRunFinish.setOnClickListener {
binding.btnRunStop.setOnClickListener {
stopTimer()
val totalTimeSec = ((timerData.hour ?: 0) * 3600) + ((timerData.minute ?: 0) * 60) + (timerData.second ?: 0)
Analytics.logEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ class RunViewModel : ViewModel() {
val dataFrom = MutableLiveData<String>()
var courseId = MutableLiveData<Int>()
var publicCourseId = MutableLiveData<Int?>()
val isPaused = MutableLiveData(false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ class TimerService : Service() {
timer?.cancel()
}

// 일시정지: 타이머만 멈추고 누적된 time은 유지한다 (resumeTimer에서 이어서 증가)
fun pauseTimer() {
timer?.cancel()
notificationBuilder.setContentText("일시정지 중")
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(NOTI_ID, notificationBuilder.build())
}

// 재개: 기존 time 값에 이어서 타이머를 다시 시작한다
fun resumeTimer() {
startTimer()
}

override fun onBind(intent: Intent?): IBinder {
return binder
}
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/bg_paused_pill.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#D1171717" />
<corners android:radius="999dp" />
</shape>
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/circle_ghost_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/W1" />
<stroke
android:width="1.5dp"
android:color="@color/G4" />
</shape>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/circle_m1_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/M1" />
</shape>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_run_pause.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M6,5h4v14h-4z"
android:fillColor="@color/W1" />
<path
android:pathData="M14,5h4v14h-4z"
android:fillColor="@color/W1" />
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_run_resume.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M7,4.5v15l13,-7.5z"
android:fillColor="@color/W1" />
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_run_stop.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M4,4h12v12h-12z"
android:fillColor="@color/G1" />
</vector>
63 changes: 50 additions & 13 deletions app/src/main/res/layout/activity_run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,59 @@
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_run_finish"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginHorizontal="15dp"
android:layout_marginBottom="18dp"
android:background="@drawable/radius_10_m1_button"
<TextView
android:id="@+id/tv_paused_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:background="@drawable/bg_paused_pill"
android:fontFamily="@font/pretendard_semibold"
android:text="@string/run_finish_run_button"
android:textAlignment="center"
android:paddingHorizontal="14dp"
android:paddingVertical="7dp"
android:text="@string/run_paused_label"
android:textColor="@color/W1"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
android:textSize="13sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_run_top_frame"
tools:visibility="visible" />

<LinearLayout
android:id="@+id/layout_run_action_dock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

<ImageButton
android:id="@+id/btn_run_stop"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginEnd="18dp"
android:background="@drawable/circle_ghost_button"
android:contentDescription="@string/run_description_stop"
android:elevation="4dp"
android:outlineProvider="none"
android:src="@drawable/ic_run_stop"
android:visibility="gone"
tools:visibility="visible" />

<ImageButton
android:id="@+id/btn_run_pause_resume"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/circle_m1_button"
android:contentDescription="@string/run_description_pause"
android:elevation="4dp"
android:outlineProvider="none"
android:src="@drawable/ic_run_pause" />

</LinearLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/btn_currentLocation"
Expand All @@ -182,7 +219,7 @@
android:src="@drawable/currentlocation"
app:backgroundTint="@color/white"
app:fabCustomSize="48dp"
app:layout_constraintBottom_toTopOf="@id/btn_run_finish"
app:layout_constraintBottom_toTopOf="@id/layout_run_action_dock"
app:layout_constraintEnd_toEndOf="parent"
app:tint="@null" />

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<string name="run_time_title">시간</string>
<string name="run_finish_run_button">러닝 종료</string>
<string name="run_description_current_location">current_location</string>
<string name="run_description_pause">일시정지</string>
<string name="run_description_resume">재개</string>
<string name="run_description_stop">러닝 종료</string>
<string name="run_paused_label">일시정지 중</string>
<string name="my_draw_edit">선택</string>

<string name="discover_upload_btn">업로드</string>
Expand Down
Loading