mirror of
				https://github.com/Kurocon/projectivy-booru-wallpaper-provider.git
				synced 2025-11-04 12:51:16 +01:00 
			
		
		
		
	Initial commit
This commit is contained in:
		
						commit
						2a6c87df54
					
				
					 41 changed files with 1398 additions and 0 deletions
				
			
		
							
								
								
									
										1
									
								
								api/.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								api/.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
/build
 | 
			
		||||
							
								
								
									
										47
									
								
								api/build.gradle.kts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								api/build.gradle.kts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
 | 
			
		||||
 | 
			
		||||
plugins {
 | 
			
		||||
    id("com.android.library")
 | 
			
		||||
    id("org.jetbrains.kotlin.android")
 | 
			
		||||
    id("kotlin-parcelize")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
android {
 | 
			
		||||
    namespace = "tv.projectivy.plugin.wallpaperprovider.api"
 | 
			
		||||
    compileSdk = 35
 | 
			
		||||
 | 
			
		||||
    defaultConfig {
 | 
			
		||||
        minSdk = 23
 | 
			
		||||
 | 
			
		||||
        consumerProguardFiles("consumer-rules.pro")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    buildFeatures {
 | 
			
		||||
        aidl = true
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    buildTypes {
 | 
			
		||||
        release {
 | 
			
		||||
            isMinifyEnabled = false
 | 
			
		||||
            proguardFiles(
 | 
			
		||||
                getDefaultProguardFile("proguard-android-optimize.txt"),
 | 
			
		||||
                "proguard-rules.pro"
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    compileOptions {
 | 
			
		||||
        sourceCompatibility = JavaVersion.VERSION_17
 | 
			
		||||
        targetCompatibility = JavaVersion.VERSION_17
 | 
			
		||||
    }
 | 
			
		||||
    kotlin {
 | 
			
		||||
        compilerOptions {
 | 
			
		||||
            jvmTarget.set(JvmTarget.JVM_17)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
    implementation("androidx.core:core-ktx:1.13.1")
 | 
			
		||||
    implementation("androidx.appcompat:appcompat:1.7.0")
 | 
			
		||||
    implementation("com.google.android.material:material:1.12.0")
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										0
									
								
								api/consumer-rules.pro
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								api/consumer-rules.pro
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										21
									
								
								api/proguard-rules.pro
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								api/proguard-rules.pro
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
# Add project specific ProGuard rules here.
 | 
			
		||||
# You can control the set of applied configuration files using the
 | 
			
		||||
# proguardFiles setting in build.gradle.
 | 
			
		||||
#
 | 
			
		||||
# For more details, see
 | 
			
		||||
#   http://developer.android.com/guide/developing/tools/proguard.html
 | 
			
		||||
 | 
			
		||||
# If your project uses WebView with JS, uncomment the following
 | 
			
		||||
# and specify the fully qualified class name to the JavaScript interface
 | 
			
		||||
# class:
 | 
			
		||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
 | 
			
		||||
#   public *;
 | 
			
		||||
#}
 | 
			
		||||
 | 
			
		||||
# Uncomment this to preserve the line number information for
 | 
			
		||||
# debugging stack traces.
 | 
			
		||||
#-keepattributes SourceFile,LineNumberTable
 | 
			
		||||
 | 
			
		||||
# If you keep the line number information, uncomment this to
 | 
			
		||||
# hide the original source file name.
 | 
			
		||||
#-renamesourcefileattribute SourceFile
 | 
			
		||||
							
								
								
									
										4
									
								
								api/src/main/AndroidManifest.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								api/src/main/AndroidManifest.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 | 
			
		||||
 | 
			
		||||
</manifest>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
// Wallpaper.aidl
 | 
			
		||||
package tv.projectivy.plugin.wallpaperprovider.api;
 | 
			
		||||
 | 
			
		||||
parcelable Event;
 | 
			
		||||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
// Wallpaper.aidl
 | 
			
		||||
package tv.projectivy.plugin.wallpaperprovider.api;
 | 
			
		||||
 | 
			
		||||
parcelable Wallpaper;
 | 
			
		||||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue