Initial commit

This commit is contained in:
Kevin Alberts 2024-12-27 01:17:26 +01:00 committed by GitHub
commit 2a6c87df54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 1398 additions and 0 deletions

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View file

@ -0,0 +1,4 @@
// Wallpaper.aidl
package tv.projectivy.plugin.wallpaperprovider.api;
parcelable Event;

View file

@ -0,0 +1,11 @@
// IWallpaperProviderService.aidl
package tv.projectivy.plugin.wallpaperprovider.api;
import tv.projectivy.plugin.wallpaperprovider.api.Wallpaper;
import tv.projectivy.plugin.wallpaperprovider.api.Event;
interface IWallpaperProviderService {
List<Wallpaper> getWallpapers(in Event event);
String getPreferences();
void setPreferences(String params);
}

View file

@ -0,0 +1,4 @@
// Wallpaper.aidl
package tv.projectivy.plugin.wallpaperprovider.api;
parcelable Wallpaper;

View file

@ -0,0 +1,68 @@
package tv.projectivy.plugin.wallpaperprovider.api
import android.os.Parcel
import android.os.Parcelable
import androidx.annotation.IntDef
import kotlinx.parcelize.Parcelize
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperUpdateEventType.Companion.CARD_FOCUSED
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperUpdateEventType.Companion.LAUNCHER_IDLE_MODE_CHANGED
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperUpdateEventType.Companion.NOW_PLAYING_CHANGED
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperUpdateEventType.Companion.PROGRAM_CARD_FOCUSED
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperUpdateEventType.Companion.TIME_ELAPSED
@Target(AnnotationTarget.TYPE)
@Retention(AnnotationRetention.SOURCE)
@IntDef(TIME_ELAPSED, NOW_PLAYING_CHANGED, CARD_FOCUSED, PROGRAM_CARD_FOCUSED, LAUNCHER_IDLE_MODE_CHANGED)
annotation class WallpaperUpdateEventType {
companion object {
const val TIME_ELAPSED = 1
const val NOW_PLAYING_CHANGED = 2
const val CARD_FOCUSED = 4
const val PROGRAM_CARD_FOCUSED = 8
const val LAUNCHER_IDLE_MODE_CHANGED = 16
}
}
sealed class Event(open val eventType: Int) : Parcelable {
companion object CREATOR : Parcelable.Creator<Event> {
override fun createFromParcel(parcel: Parcel): Event? {
val initialDataPosition = parcel.dataPosition() // save current data position
val eventType = parcel.readInt() // get the Event type for dynamic creation
parcel.setDataPosition(initialDataPosition) // reset position to let the specialized CREATOR read from start
return when(eventType) {
TIME_ELAPSED -> createEventFromParcel(parcel, TimeElapsed::class.java)
NOW_PLAYING_CHANGED -> createEventFromParcel(parcel, NowPlayingChanged::class.java)
CARD_FOCUSED -> createEventFromParcel(parcel, CardFocused::class.java)
PROGRAM_CARD_FOCUSED -> createEventFromParcel(parcel, ProgramCardFocused::class.java)
LAUNCHER_IDLE_MODE_CHANGED -> createEventFromParcel(parcel, LauncherIdleModeChanged::class.java)
else -> null
}
}
override fun newArray(size: Int): Array<Event?> {
return arrayOfNulls(size)
}
private fun <T> createEventFromParcel(parcel: Parcel, clazz: Class<T>): T {
val creatorField = clazz.getField("CREATOR")
val creator = creatorField.get(null) as Parcelable.Creator<*>
return creator.createFromParcel(parcel) as T
}
}
@Parcelize
data class TimeElapsed(override val eventType: Int = TIME_ELAPSED): Event(eventType)
@Parcelize
data class NowPlayingChanged(override val eventType: Int = NOW_PLAYING_CHANGED, val isPlaying: Boolean = true, val title: String?=null, val artist: String?=null, val album: String?=null, val iconUri: String?=null): Event(eventType)
@Parcelize
data class CardFocused(override val eventType: Int = CARD_FOCUSED, val lightColor: Int=0, val darkColor: Int=0): Event(eventType)
// type refers to TYPE_* in TvContractCompat.PreviewProgramColumns
@Parcelize
data class ProgramCardFocused(override val eventType: Int = PROGRAM_CARD_FOCUSED, val title: String?=null, val type: Int?=null, val iconUri: String?=null, val iconAspectRatio: Int=0): Event(eventType)
@Parcelize
data class LauncherIdleModeChanged(override val eventType: Int = LAUNCHER_IDLE_MODE_CHANGED, val isIdle: Boolean = true): Event(eventType)
}

View file

@ -0,0 +1,51 @@
package tv.projectivy.plugin.wallpaperprovider.api
import android.os.Parcelable
import androidx.annotation.IntDef
import kotlinx.parcelize.Parcelize
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperDisplayMode.Companion.BLUR
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperDisplayMode.Companion.CROP
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperDisplayMode.Companion.DEFAULT
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperDisplayMode.Companion.STRETCH
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperType.Companion.ANIMATED_DRAWABLE
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperType.Companion.DRAWABLE
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperType.Companion.IMAGE
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperType.Companion.LOTTIE
import tv.projectivy.plugin.wallpaperprovider.api.WallpaperType.Companion.VIDEO
@Target(AnnotationTarget.TYPE)
@Retention(AnnotationRetention.SOURCE)
@IntDef(IMAGE, DRAWABLE, ANIMATED_DRAWABLE, LOTTIE, VIDEO)
annotation class WallpaperType {
companion object {
const val IMAGE = 0
const val DRAWABLE = 1
const val ANIMATED_DRAWABLE = 2
const val LOTTIE = 3
const val VIDEO = 4
}
}
@Target(AnnotationTarget.TYPE, AnnotationTarget.VALUE_PARAMETER)
@Retention(AnnotationRetention.SOURCE)
@IntDef(DEFAULT, CROP, STRETCH, BLUR)
annotation class WallpaperDisplayMode {
companion object {
const val DEFAULT = 0
const val CROP = 1
const val STRETCH = 2
const val BLUR = 3
}
}
@Parcelize
data class Wallpaper(
val uri: String,
val type: @WallpaperType Int = IMAGE,
val displayMode: @WallpaperDisplayMode Int = CROP,
val title: String? = null,
val source: String? = null,
val author: String? = null,
val actionUri: String? = null
) : Parcelable