Skip to content

Commit 467fcc3

Browse files
committed
fix: action log for all actions, running badge logic (no badge = running)
1 parent 66dabd5 commit 467fcc3

File tree

3 files changed

+28
-33
lines changed

3 files changed

+28
-33
lines changed

app/src/main/java/com/appcontrolx/ui/AppDetailBottomSheet.kt

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -314,19 +314,18 @@ class AppDetailBottomSheet : BottomSheetDialogFragment() {
314314
val success = result?.isSuccess == true
315315

316316
// Log action - always log for all action types
317-
if (appInfo != null && rollbackManager != null) {
318-
val finalLogAction = logActionName ?: actionName.uppercase().replace(" ", "_")
319-
withContext(Dispatchers.IO) {
320-
timber.log.Timber.d("Manual action: $finalLogAction, success=$success")
321-
rollbackManager!!.logAction(ActionLog(
322-
action = finalLogAction,
323-
packages = listOf(appInfo!!.packageName),
324-
success = success,
325-
message = if (success) null else "Failed"
326-
))
317+
appInfo?.let { app ->
318+
rollbackManager?.let { rm ->
319+
val finalLogAction = logActionName ?: actionName.uppercase().replace(" ", "_")
320+
withContext(Dispatchers.IO) {
321+
rm.logAction(ActionLog(
322+
action = finalLogAction,
323+
packages = listOf(app.packageName),
324+
success = success,
325+
message = if (success) null else "Failed"
326+
))
327+
}
327328
}
328-
} else {
329-
timber.log.Timber.w("Cannot log: appInfo=${appInfo != null}, rm=${rollbackManager != null}")
330329
}
331330

332331
if (success) {
@@ -369,18 +368,17 @@ class AppDetailBottomSheet : BottomSheetDialogFragment() {
369368
val success = result?.isSuccess == true
370369

371370
// Log action
372-
if (appInfo != null && rollbackManager != null) {
373-
withContext(Dispatchers.IO) {
374-
timber.log.Timber.d("Background action: $logActionName, success=$success")
375-
rollbackManager!!.logAction(ActionLog(
376-
action = logActionName,
377-
packages = listOf(appInfo!!.packageName),
378-
success = success,
379-
message = if (success) null else "Failed"
380-
))
371+
appInfo?.let { app ->
372+
rollbackManager?.let { rm ->
373+
withContext(Dispatchers.IO) {
374+
rm.logAction(ActionLog(
375+
action = logActionName,
376+
packages = listOf(app.packageName),
377+
success = success,
378+
message = if (success) null else "Failed"
379+
))
380+
}
381381
}
382-
} else {
383-
timber.log.Timber.w("Cannot log bg action: appInfo=${appInfo != null}, rm=${rollbackManager != null}")
384382
}
385383

386384
if (success) {

app/src/main/java/com/appcontrolx/ui/AppListFragment.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,18 +419,15 @@ class AppListFragment : Fragment() {
419419
},
420420
onComplete = { successCount, failCount ->
421421
// Log action - always log regardless of action type
422-
if (rm != null) {
422+
rm?.let { manager ->
423423
lifecycleScope.launch(Dispatchers.IO) {
424-
timber.log.Timber.d("Batch complete: ${action.name}, success=$successCount, fail=$failCount")
425-
rm.logAction(ActionLog(
424+
manager.logAction(ActionLog(
426425
action = action.name,
427426
packages = packages,
428427
success = failCount == 0,
429428
message = if (failCount == 0) "All $successCount succeeded" else "$failCount failed"
430429
))
431430
}
432-
} else {
433-
timber.log.Timber.w("RollbackManager is null, cannot log action")
434431
}
435432

436433
adapter.deselectAll()

app/src/main/java/com/appcontrolx/ui/adapter/AppListAdapter.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ class AppListAdapter(
113113
root.alpha = if (app.isEnabled) 1f else 0.6f
114114

115115
// Status badges
116-
// Running detection: if not frozen, not stopped, not restricted = running
117-
val isEffectivelyRunning = !app.isFrozen && !app.isStopped && !app.isBackgroundRestricted
118-
val hasAnyBadge = app.isFrozen || isEffectivelyRunning || app.isStopped || app.isBackgroundRestricted
119-
statusContainer.visibility = if (hasAnyBadge) View.VISIBLE else View.GONE
116+
// New logic: No badge (not frozen, not stopped) = RUNNING
117+
// RUNNING can coexist with BACKGROUND RESTRICTED
118+
val isRunning = !app.isFrozen && !app.isStopped
119+
statusContainer.visibility = View.VISIBLE // Always show container
120120

121121
tvStatusFrozen.visibility = if (app.isFrozen) View.VISIBLE else View.GONE
122-
tvStatusRunning.visibility = if (isEffectivelyRunning) View.VISIBLE else View.GONE
122+
tvStatusRunning.visibility = if (isRunning) View.VISIBLE else View.GONE
123123
tvStatusStopped.visibility = if (app.isStopped && !app.isFrozen) View.VISIBLE else View.GONE
124124
tvStatusRestricted.visibility = if (app.isBackgroundRestricted && !app.isFrozen) View.VISIBLE else View.GONE
125125

0 commit comments

Comments
 (0)