mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
refactor(tasks): remove isEnableUrl config, always enable URL parsing
This commit is contained in:
parent
853bbcf268
commit
2844560ef8
8 changed files with 145 additions and 25 deletions
|
|
@ -116,7 +116,11 @@ class FocusModeForegroundService : Service() {
|
|||
}
|
||||
|
||||
ACTION_STOP -> {
|
||||
stopFocusMode()
|
||||
if (isRunning) {
|
||||
stopFocusMode()
|
||||
} else {
|
||||
Log.d(TAG, "Ignoring STOP action - service not running")
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,11 @@ class TrackingForegroundService : Service() {
|
|||
}
|
||||
|
||||
ACTION_STOP -> {
|
||||
stopTracking()
|
||||
if (isTracking) {
|
||||
stopTracking()
|
||||
} else {
|
||||
Log.d(TAG, "Ignoring STOP action - service not tracking")
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.superproductivity.superproductivity.webview
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.ForegroundServiceStartNotAllowedException
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import android.webkit.JavascriptInterface
|
||||
import android.webkit.WebView
|
||||
|
|
@ -26,7 +28,11 @@ class JavaScriptInterface(
|
|||
try {
|
||||
block()
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, errorMsg, e)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && e is ForegroundServiceStartNotAllowedException) {
|
||||
Log.e(TAG, "$errorMsg - ForegroundService restrictions violated (Android 12+). App may be in background.", e)
|
||||
} else {
|
||||
Log.e(TAG, errorMsg, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,10 +109,8 @@ class JavaScriptInterface(
|
|||
@JavascriptInterface
|
||||
fun stopTrackingService() {
|
||||
safeCall("Failed to stop tracking service") {
|
||||
val intent = Intent(activity, TrackingForegroundService::class.java).apply {
|
||||
action = TrackingForegroundService.ACTION_STOP
|
||||
}
|
||||
activity.startService(intent)
|
||||
val intent = Intent(activity, TrackingForegroundService::class.java)
|
||||
activity.stopService(intent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,10 +167,8 @@ class JavaScriptInterface(
|
|||
@JavascriptInterface
|
||||
fun stopFocusModeService() {
|
||||
safeCall("Failed to stop focus mode service") {
|
||||
val intent = Intent(activity, FocusModeForegroundService::class.java).apply {
|
||||
action = FocusModeForegroundService.ACTION_STOP
|
||||
}
|
||||
activity.startService(intent)
|
||||
val intent = Intent(activity, FocusModeForegroundService::class.java)
|
||||
activity.stopService(intent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue