diff --git a/app/build.gradle b/app/build.gradle
index e43141a3c..f74962d9c 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -151,6 +151,9 @@ dependencies {
// Speed dial
implementation "com.leinardi.android:speed-dial:3.3.0"
+ // Tasker
+ implementation 'com.joaomgcd:taskerpluginlibrary:0.4.10'
+
// Testing
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
testImplementation "junit:junit:4.13.2"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 53c1b4e2b..a65f67788 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -134,5 +134,18 @@
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/org/oxycblt/auxio/AuxioService.kt b/app/src/main/java/org/oxycblt/auxio/AuxioService.kt
index 64121e6d1..fd44f6a5b 100644
--- a/app/src/main/java/org/oxycblt/auxio/AuxioService.kt
+++ b/app/src/main/java/org/oxycblt/auxio/AuxioService.kt
@@ -28,6 +28,8 @@ import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import org.oxycblt.auxio.music.service.IndexerServiceFragment
import org.oxycblt.auxio.playback.service.MediaSessionServiceFragment
+import org.oxycblt.auxio.tasker.indicateServiceRunning
+import org.oxycblt.auxio.tasker.indicateServiceStopped
@AndroidEntryPoint
class AuxioService : MediaLibraryService(), ForegroundListener {
@@ -40,6 +42,7 @@ class AuxioService : MediaLibraryService(), ForegroundListener {
super.onCreate()
mediaSessionFragment.attach(this, this)
indexingFragment.attach(this)
+ indicateServiceRunning()
}
override fun onBind(intent: Intent?): IBinder? {
@@ -70,6 +73,7 @@ class AuxioService : MediaLibraryService(), ForegroundListener {
override fun onDestroy() {
super.onDestroy()
+ indicateServiceStopped()
indexingFragment.release()
mediaSessionFragment.release()
}
diff --git a/app/src/main/java/org/oxycblt/auxio/tasker/Start.kt b/app/src/main/java/org/oxycblt/auxio/tasker/Start.kt
new file mode 100644
index 000000000..0191e0133
--- /dev/null
+++ b/app/src/main/java/org/oxycblt/auxio/tasker/Start.kt
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2024 Auxio Project
+ * Start.kt is part of Auxio.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package org.oxycblt.auxio.tasker
+
+import android.app.Activity
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import androidx.core.content.ContextCompat
+import com.joaomgcd.taskerpluginlibrary.action.TaskerPluginRunnerActionNoOutputOrInput
+import com.joaomgcd.taskerpluginlibrary.config.TaskerPluginConfig
+import com.joaomgcd.taskerpluginlibrary.config.TaskerPluginConfigHelperNoOutputOrInput
+import com.joaomgcd.taskerpluginlibrary.config.TaskerPluginConfigNoInput
+import com.joaomgcd.taskerpluginlibrary.input.TaskerInput
+import com.joaomgcd.taskerpluginlibrary.runner.TaskerPluginResult
+import com.joaomgcd.taskerpluginlibrary.runner.TaskerPluginResultSucess
+import org.oxycblt.auxio.AuxioService
+
+private var serviceRunning = false
+
+fun indicateServiceRunning() {
+ serviceRunning = true
+}
+
+fun indicateServiceStopped() {
+ serviceRunning = false
+}
+
+class StartActionHelper(config: TaskerPluginConfig) :
+ TaskerPluginConfigHelperNoOutputOrInput(config) {
+ override val runnerClass: Class
+ get() = StartActionRunner::class.java
+
+ override fun addToStringBlurb(input: TaskerInput, blurbBuilder: StringBuilder) {
+ blurbBuilder.append(
+ "Starts the Auxio Service. This will block until the service is fully initialized." +
+ "You must start active playback/foreground state after this or Auxio may" +
+ "crash.")
+ }
+}
+
+class StartConfigBasicAction : Activity(), TaskerPluginConfigNoInput {
+ override val context: Context
+ get() = applicationContext
+
+ private val taskerHelper by lazy { StartActionHelper(this) }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ taskerHelper.finishForTasker()
+ }
+}
+
+class StartActionRunner : TaskerPluginRunnerActionNoOutputOrInput() {
+ override fun run(context: Context, input: TaskerInput): TaskerPluginResult {
+ ContextCompat.startForegroundService(context, Intent(context, AuxioService::class.java))
+ while (!serviceRunning) {
+ Thread.sleep(100)
+ }
+
+ return TaskerPluginResultSucess()
+ }
+}
diff --git a/app/src/main/java/org/oxycblt/auxio/tasker/Tasker.kt b/app/src/main/java/org/oxycblt/auxio/tasker/Tasker.kt
deleted file mode 100644
index ec2d6ac99..000000000
--- a/app/src/main/java/org/oxycblt/auxio/tasker/Tasker.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2024 Auxio Project
- * Tasker.kt is part of Auxio.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.oxycblt.auxio.tasker