Skip to content

Commit

Permalink
Added support for Tasker event trigger when wallpaper changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthonyy232 committed Sep 25, 2024
1 parent 1c7ae97 commit aa3ce3b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
minSdk = 26
targetSdk = 35
versionCode = 31
versionName = "2.2.0"
versionName = "2.2.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<meta-data android:name="androidx.emoji2.text.EmojiCompatInitializer"
tools:node="remove" />
</provider>

<activity
android:name=".feature.wallpaper.tasker_shortcut.ActivityConfigBasicAction"
android:exported="true"
Expand All @@ -69,5 +70,13 @@
<action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING" />
</intent-filter>
</activity>
<activity android:name=".feature.wallpaper.tasker_shortcut.ActivityConfigBasicEvent"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:label="Change wallpaper event">
<intent-filter>
<action android:name="net.dinglisch.android.tasker.ACTION_EDIT_EVENT" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.anthonyla.paperize.feature.wallpaper.tasker_shortcut

import android.app.Activity
import android.content.Context
import android.os.Bundle
import com.joaomgcd.taskerpluginlibrary.config.TaskerPluginConfig
import com.joaomgcd.taskerpluginlibrary.config.TaskerPluginConfigHelperEventNoOutputOrInputOrUpdate
import com.joaomgcd.taskerpluginlibrary.config.TaskerPluginConfigNoInput
import com.joaomgcd.taskerpluginlibrary.extensions.requestQuery
import com.joaomgcd.taskerpluginlibrary.input.TaskerInput

class BasicEventHelper(config: TaskerPluginConfig<Unit>) : TaskerPluginConfigHelperEventNoOutputOrInputOrUpdate(config) {
override fun addToStringBlurb(input: TaskerInput<Unit>, blurbBuilder: StringBuilder) {
blurbBuilder.append("Triggers when the app changes the wallpaper")
}
}

class ActivityConfigBasicEvent : Activity(), TaskerPluginConfigNoInput {
override val context: Context get() = applicationContext
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
BasicEventHelper(this).finishForTasker()
}
}

fun Context.triggerWallpaperTaskerEvent() = ActivityConfigBasicEvent::class.java.requestQuery(this)

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
import com.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
import com.anthonyla.paperize.feature.wallpaper.domain.repository.SelectedAlbumRepository
import com.anthonyla.paperize.feature.wallpaper.presentation.MainActivity
import com.anthonyla.paperize.feature.wallpaper.tasker_shortcut.triggerWallpaperTaskerEvent
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperBootAndChangeReceiver
import com.lazygeniouz.dfc.file.DocumentFileCompat
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -578,6 +579,7 @@ class HomeWallpaperService: Service() {
image.recycle()
}
bitmap.recycle()
context.triggerWallpaperTaskerEvent()
return true
}
else return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
import com.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
import com.anthonyla.paperize.feature.wallpaper.domain.repository.SelectedAlbumRepository
import com.anthonyla.paperize.feature.wallpaper.presentation.MainActivity
import com.anthonyla.paperize.feature.wallpaper.tasker_shortcut.triggerWallpaperTaskerEvent
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperBootAndChangeReceiver
import com.lazygeniouz.dfc.file.DocumentFileCompat
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -500,6 +501,7 @@ class LockWallpaperService: Service() {
image.recycle()
}
bitmap.recycle()
context.triggerWallpaperTaskerEvent()
return true
}
else return false
Expand Down

0 comments on commit aa3ce3b

Please sign in to comment.