Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e18f3eceb9 | ||
|
|
22cc66687e | ||
|
|
fc90aeaa78 | ||
|
|
7fb0f8e824 | ||
|
|
3fccae4273 | ||
|
|
65a2f66344 | ||
|
|
93af870235 | ||
|
|
51f4ac310a |
No files matched your search
@@ -41,10 +41,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository source code
|
||||
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
@@ -70,10 +70,10 @@ jobs:
|
||||
if: github.event_name == 'push'
|
||||
steps:
|
||||
- name: Checkout repository source code
|
||||
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
@@ -154,7 +154,7 @@ jobs:
|
||||
- name: Create Draft Release
|
||||
# Publishes a new release to GitHub. `draft: true` ensures the release is not made
|
||||
# public until it has been manually reviewed and published.
|
||||
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3
|
||||
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3
|
||||
with:
|
||||
files: ./apk-artifact/paperize-v*.apk
|
||||
draft: true
|
||||
|
||||
@@ -18,33 +18,33 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository source code
|
||||
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
|
||||
uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
|
||||
with:
|
||||
languages: actions
|
||||
build-mode: none
|
||||
|
||||
- name: Perform CodeQL analysis
|
||||
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
|
||||
uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
|
||||
|
||||
analyze-java-kotlin:
|
||||
name: Analyze Java and Kotlin
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository source code
|
||||
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6
|
||||
with:
|
||||
java-version: "17"
|
||||
distribution: temurin
|
||||
cache: gradle
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
|
||||
uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
|
||||
with:
|
||||
languages: java-kotlin
|
||||
build-mode: manual
|
||||
@@ -56,4 +56,4 @@ jobs:
|
||||
run: ./gradlew assembleDebug
|
||||
|
||||
- name: Perform CodeQL analysis
|
||||
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
|
||||
uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
|
||||
@@ -1,3 +1,34 @@
|
||||
## v4.1.1
|
||||
|
||||
- Fixed manual changes triggering an immediate extra automatic change by deferring
|
||||
the next run for the full interval and preserving it across settings updates.
|
||||
- Added Simplified Chinese translations for setup, settings, wallpaper controls,
|
||||
notifications, and accessibility labels, with Android app-language support.
|
||||
- Corrected the privacy notice to explain that Paperize displays its own
|
||||
notifications and does not read notifications from other apps.
|
||||
|
||||
## New Contributors
|
||||
|
||||
* @zxiaoshen made their first contribution in https://github.com/Anthonyy232/Paperize/pull/605
|
||||
|
||||
**Full Changelog**: https://github.com/Anthonyy232/Paperize/compare/v4.1.0...v4.1.1
|
||||
|
||||
## v4.1.0
|
||||
|
||||
- Added a Set wallpaper action to image previews, with separate home, lock, and
|
||||
combined home-and-lock targets that preserve each screen's scaling and effects.
|
||||
- Reset the affected automatic countdown after a successful manual change from
|
||||
Paperize, its launcher shortcut, or its Quick Settings tile.
|
||||
- Added live-wallpaper intervals as short as one minute while the wallpaper is
|
||||
visible, with lifecycle-aware pausing and timer resets after manual changes.
|
||||
- Replaced the undersized status-bar asset with a dedicated notification icon.
|
||||
- Updated Paperize for the Android 17 SDK and refreshed Kotlin, Gradle, Compose,
|
||||
AndroidX, Material, Coil, Zoomable, and GitHub Actions dependencies.
|
||||
- Expanded emulator coverage for Android wallpaper colors, every static and live
|
||||
visual effect, OpenGL shaders, scheduling policy, and foldable display sizing.
|
||||
|
||||
**Full Changelog**: https://github.com/Anthonyy232/Paperize/compare/v4.0.3...v4.1.0
|
||||
|
||||
## v4.0.3
|
||||
|
||||
- Kept scheduled static changes in the device's natural orientation, even when a
|
||||
|
||||
@@ -14,7 +14,7 @@ ksp {
|
||||
|
||||
android {
|
||||
namespace = "com.anthonyla.paperize"
|
||||
compileSdk = 36
|
||||
compileSdk = 37
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
@@ -32,8 +32,8 @@ android {
|
||||
applicationId = "com.anthonyla.paperize"
|
||||
minSdk = 31
|
||||
targetSdk = 36
|
||||
versionCode = 54
|
||||
versionName = "4.0.3"
|
||||
versionCode = 56
|
||||
versionName = "4.1.1"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
|
||||
+52
-1
@@ -1,11 +1,13 @@
|
||||
package com.anthonyla.paperize.core.util
|
||||
|
||||
import android.app.WallpaperManager
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.content.res.Configuration
|
||||
import android.os.SystemClock
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
@@ -225,6 +227,55 @@ class WallpaperUtilInstrumentedTest {
|
||||
result.recycle()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun staticWallpaperChangesRefreshAospWallpaperColors() {
|
||||
assumeTrue(
|
||||
"Wallpaper color extraction test is destructive and must run only on an emulator",
|
||||
Build.FINGERPRINT.contains("/emu") ||
|
||||
Build.FINGERPRINT.contains("generic") ||
|
||||
Build.MODEL.contains("Emulator", ignoreCase = true) ||
|
||||
Build.MODEL.contains("sdk", ignoreCase = true)
|
||||
)
|
||||
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||
val red = mutableBitmap(256, 256, Color.rgb(230, 20, 20))
|
||||
val blue = mutableBitmap(256, 256, Color.rgb(20, 20, 230))
|
||||
|
||||
try {
|
||||
wallpaperManager.setBitmapChecked(red, WallpaperManager.FLAG_SYSTEM)
|
||||
val redPrimary = awaitPrimaryWallpaperColor(wallpaperManager) { color ->
|
||||
Color.red(color) > Color.blue(color) * 2
|
||||
}
|
||||
|
||||
wallpaperManager.setBitmapChecked(blue, WallpaperManager.FLAG_SYSTEM)
|
||||
val bluePrimary = awaitPrimaryWallpaperColor(wallpaperManager) { color ->
|
||||
Color.blue(color) > Color.red(color) * 2
|
||||
}
|
||||
|
||||
assertTrue(Color.red(redPrimary) > Color.blue(redPrimary))
|
||||
assertTrue(Color.blue(bluePrimary) > Color.red(bluePrimary))
|
||||
} finally {
|
||||
red.recycle()
|
||||
blue.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
private fun awaitPrimaryWallpaperColor(
|
||||
wallpaperManager: WallpaperManager,
|
||||
predicate: (Int) -> Boolean
|
||||
): Int {
|
||||
val deadline = SystemClock.uptimeMillis() + 10_000L
|
||||
var lastColor: Int? = null
|
||||
while (SystemClock.uptimeMillis() < deadline) {
|
||||
lastColor = wallpaperManager
|
||||
.getWallpaperColors(WallpaperManager.FLAG_SYSTEM)
|
||||
?.primaryColor
|
||||
?.toArgb()
|
||||
if (lastColor != null && predicate(lastColor)) return lastColor
|
||||
SystemClock.sleep(100L)
|
||||
}
|
||||
throw AssertionError("Wallpaper colors did not refresh; last primary color was $lastColor")
|
||||
}
|
||||
|
||||
private fun mutableBitmap(width: Int, height: Int, color: Int): Bitmap =
|
||||
Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888).apply {
|
||||
eraseColor(color)
|
||||
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
package com.anthonyla.paperize.service.livewallpaper.renderer
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.opengl.EGL14
|
||||
import android.opengl.EGLConfig
|
||||
import android.opengl.EGLContext
|
||||
import android.opengl.EGLDisplay
|
||||
import android.opengl.EGLSurface
|
||||
import android.opengl.GLES20
|
||||
import android.opengl.GLUtils
|
||||
import android.opengl.Matrix
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.anthonyla.paperize.service.livewallpaper.gl.GLUtil
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.nio.FloatBuffer
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LiveWallpaperShaderInstrumentedTest {
|
||||
private lateinit var display: EGLDisplay
|
||||
private lateinit var context: EGLContext
|
||||
private lateinit var surface: EGLSurface
|
||||
|
||||
@Before
|
||||
fun createGlContext() {
|
||||
display = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY)
|
||||
assertTrue(display != EGL14.EGL_NO_DISPLAY)
|
||||
assertTrue(EGL14.eglInitialize(display, IntArray(2), 0, IntArray(2), 0))
|
||||
|
||||
val configs = arrayOfNulls<EGLConfig>(1)
|
||||
val configCount = IntArray(1)
|
||||
assertTrue(
|
||||
EGL14.eglChooseConfig(
|
||||
display,
|
||||
intArrayOf(
|
||||
EGL14.EGL_SURFACE_TYPE, EGL14.EGL_PBUFFER_BIT,
|
||||
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
|
||||
EGL14.EGL_RED_SIZE, 8,
|
||||
EGL14.EGL_GREEN_SIZE, 8,
|
||||
EGL14.EGL_BLUE_SIZE, 8,
|
||||
EGL14.EGL_ALPHA_SIZE, 8,
|
||||
EGL14.EGL_NONE
|
||||
),
|
||||
0,
|
||||
configs,
|
||||
0,
|
||||
configs.size,
|
||||
configCount,
|
||||
0
|
||||
)
|
||||
)
|
||||
val config = requireNotNull(configs.first())
|
||||
context = EGL14.eglCreateContext(
|
||||
display,
|
||||
config,
|
||||
EGL14.EGL_NO_CONTEXT,
|
||||
intArrayOf(EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE),
|
||||
0
|
||||
)
|
||||
surface = EGL14.eglCreatePbufferSurface(
|
||||
display,
|
||||
config,
|
||||
intArrayOf(EGL14.EGL_WIDTH, SIZE, EGL14.EGL_HEIGHT, SIZE, EGL14.EGL_NONE),
|
||||
0
|
||||
)
|
||||
assertTrue(EGL14.eglMakeCurrent(display, surface, surface, context))
|
||||
GLES20.glViewport(0, 0, SIZE, SIZE)
|
||||
GLES20.glDisable(GLES20.GL_BLEND)
|
||||
}
|
||||
|
||||
@After
|
||||
fun destroyGlContext() {
|
||||
EGL14.eglMakeCurrent(
|
||||
display,
|
||||
EGL14.EGL_NO_SURFACE,
|
||||
EGL14.EGL_NO_SURFACE,
|
||||
EGL14.EGL_NO_CONTEXT
|
||||
)
|
||||
EGL14.eglDestroySurface(display, surface)
|
||||
EGL14.eglDestroyContext(display, context)
|
||||
EGL14.eglTerminate(display)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun everyLiveWallpaperShaderCompilesAndLinksOnDevice() {
|
||||
listOf(
|
||||
GLShaders.SIMPLE_FRAGMENT_SHADER,
|
||||
GLShaders.BLUR_HORIZONTAL_FRAGMENT_SHADER,
|
||||
GLShaders.BLUR_VERTICAL_FRAGMENT_SHADER,
|
||||
GLShaders.EFFECTS_FRAGMENT_SHADER
|
||||
).forEach { fragmentShader ->
|
||||
val program = GLUtil.createProgram(GLShaders.VERTEX_SHADER, fragmentShader)
|
||||
assertTrue(program != 0)
|
||||
GLES20.glDeleteProgram(program)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun liveColorEffectsChangeRenderedPixels() {
|
||||
val sourceColor = Color.rgb(200, 100, 40)
|
||||
val texture = createTexture(solidBitmap(sourceColor))
|
||||
val program = GLUtil.createProgram(GLShaders.VERTEX_SHADER, GLShaders.EFFECTS_FRAGMENT_SHADER)
|
||||
|
||||
try {
|
||||
drawEffects(program, texture)
|
||||
val baseline = readPixel(SIZE / 2, SIZE / 2)
|
||||
assertTrue(Color.red(baseline) in 195..205)
|
||||
assertTrue(Color.green(baseline) in 95..105)
|
||||
|
||||
drawEffects(program, texture, darken = 1f)
|
||||
assertTrue(Color.red(readPixel(SIZE / 2, SIZE / 2)) <= 2)
|
||||
|
||||
drawEffects(program, texture, grayscale = 1f)
|
||||
val gray = readPixel(SIZE / 2, SIZE / 2)
|
||||
assertTrue(kotlin.math.abs(Color.red(gray) - Color.green(gray)) <= 2)
|
||||
assertTrue(kotlin.math.abs(Color.green(gray) - Color.blue(gray)) <= 2)
|
||||
|
||||
drawEffects(program, texture, adaptiveBrightness = 0.5f)
|
||||
val dimmed = readPixel(SIZE / 2, SIZE / 2)
|
||||
assertTrue(Color.red(dimmed) in 95..105)
|
||||
|
||||
drawEffects(program, texture, vignette = 1f)
|
||||
val center = Color.red(readPixel(SIZE / 2, SIZE / 2))
|
||||
val corner = Color.red(readPixel(1, 1))
|
||||
assertTrue("Expected vignette corner $corner below center $center", corner < center)
|
||||
} finally {
|
||||
GLES20.glDeleteProgram(program)
|
||||
GLES20.glDeleteTextures(1, intArrayOf(texture), 0)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun liveBlurShadersSoftenHorizontalAndVerticalBoundaries() {
|
||||
val horizontal = boundaryBitmap(horizontalBoundary = true)
|
||||
val vertical = boundaryBitmap(horizontalBoundary = false)
|
||||
val horizontalTexture = createTexture(horizontal)
|
||||
val verticalTexture = createTexture(vertical)
|
||||
|
||||
val horizontalProgram = GLUtil.createProgram(
|
||||
GLShaders.VERTEX_SHADER,
|
||||
GLShaders.BLUR_HORIZONTAL_FRAGMENT_SHADER
|
||||
)
|
||||
val verticalProgram = GLUtil.createProgram(
|
||||
GLShaders.VERTEX_SHADER,
|
||||
GLShaders.BLUR_VERTICAL_FRAGMENT_SHADER
|
||||
)
|
||||
try {
|
||||
drawBlur(horizontalProgram, horizontalTexture)
|
||||
assertTrue(Color.red(readPixel(SIZE / 2, SIZE / 2)) in 10..245)
|
||||
|
||||
drawBlur(verticalProgram, verticalTexture)
|
||||
assertTrue(Color.red(readPixel(SIZE / 2, SIZE / 2)) in 10..245)
|
||||
} finally {
|
||||
GLES20.glDeleteProgram(horizontalProgram)
|
||||
GLES20.glDeleteProgram(verticalProgram)
|
||||
GLES20.glDeleteTextures(2, intArrayOf(horizontalTexture, verticalTexture), 0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawEffects(
|
||||
program: Int,
|
||||
texture: Int,
|
||||
darken: Float = 0f,
|
||||
vignette: Float = 0f,
|
||||
grayscale: Float = 0f,
|
||||
adaptiveBrightness: Float = 1f
|
||||
) {
|
||||
prepareDraw(program, texture)
|
||||
GLES20.glUniform1f(GLES20.glGetUniformLocation(program, "u_alpha"), 1f)
|
||||
GLES20.glUniform1f(GLES20.glGetUniformLocation(program, "u_darkenFactor"), darken)
|
||||
GLES20.glUniform1f(GLES20.glGetUniformLocation(program, "u_vignetteFactor"), vignette)
|
||||
GLES20.glUniform1f(GLES20.glGetUniformLocation(program, "u_grayscaleFactor"), grayscale)
|
||||
GLES20.glUniform1f(
|
||||
GLES20.glGetUniformLocation(program, "u_adaptiveBrightnessFactor"),
|
||||
adaptiveBrightness
|
||||
)
|
||||
finishDraw(program)
|
||||
}
|
||||
|
||||
private fun drawBlur(program: Int, texture: Int) {
|
||||
prepareDraw(program, texture)
|
||||
GLES20.glUniform2f(GLES20.glGetUniformLocation(program, "u_resolution"), SIZE.toFloat(), SIZE.toFloat())
|
||||
GLES20.glUniform1f(GLES20.glGetUniformLocation(program, "u_blurRadius"), 4f)
|
||||
finishDraw(program)
|
||||
}
|
||||
|
||||
private fun prepareDraw(program: Int, texture: Int) {
|
||||
GLES20.glClearColor(0f, 0f, 0f, 1f)
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT)
|
||||
GLES20.glUseProgram(program)
|
||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0)
|
||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture)
|
||||
GLES20.glUniform1i(GLES20.glGetUniformLocation(program, "u_texture"), 0)
|
||||
|
||||
val identity = FloatArray(16).also { Matrix.setIdentityM(it, 0) }
|
||||
GLES20.glUniformMatrix4fv(
|
||||
GLES20.glGetUniformLocation(program, "u_mvpMatrix"),
|
||||
1,
|
||||
false,
|
||||
identity,
|
||||
0
|
||||
)
|
||||
|
||||
val position = GLES20.glGetAttribLocation(program, "a_position")
|
||||
val textureCoordinate = GLES20.glGetAttribLocation(program, "a_texCoord")
|
||||
GLES20.glEnableVertexAttribArray(position)
|
||||
GLES20.glEnableVertexAttribArray(textureCoordinate)
|
||||
GLES20.glVertexAttribPointer(position, 2, GLES20.GL_FLOAT, false, 0, floatBuffer(VERTICES))
|
||||
GLES20.glVertexAttribPointer(
|
||||
textureCoordinate,
|
||||
2,
|
||||
GLES20.GL_FLOAT,
|
||||
false,
|
||||
0,
|
||||
floatBuffer(TEXTURE_COORDINATES)
|
||||
)
|
||||
}
|
||||
|
||||
private fun finishDraw(program: Int) {
|
||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4)
|
||||
GLES20.glFinish()
|
||||
GLES20.glDisableVertexAttribArray(GLES20.glGetAttribLocation(program, "a_position"))
|
||||
GLES20.glDisableVertexAttribArray(GLES20.glGetAttribLocation(program, "a_texCoord"))
|
||||
GLUtil.checkGLError("live wallpaper shader draw")
|
||||
}
|
||||
|
||||
private fun createTexture(bitmap: Bitmap): Int {
|
||||
val texture = IntArray(1)
|
||||
GLES20.glGenTextures(1, texture, 0)
|
||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture[0])
|
||||
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR)
|
||||
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR)
|
||||
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE)
|
||||
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE)
|
||||
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0)
|
||||
if (!bitmap.isRecycled) bitmap.recycle()
|
||||
return texture[0]
|
||||
}
|
||||
|
||||
private fun readPixel(x: Int, y: Int): Int {
|
||||
val buffer = ByteBuffer.allocateDirect(4)
|
||||
GLES20.glReadPixels(x, y, 1, 1, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buffer)
|
||||
return Color.argb(
|
||||
buffer.get(3).toInt() and 0xff,
|
||||
buffer.get(0).toInt() and 0xff,
|
||||
buffer.get(1).toInt() and 0xff,
|
||||
buffer.get(2).toInt() and 0xff
|
||||
)
|
||||
}
|
||||
|
||||
private fun solidBitmap(color: Int): Bitmap =
|
||||
Bitmap.createBitmap(SIZE, SIZE, Bitmap.Config.ARGB_8888).apply { eraseColor(color) }
|
||||
|
||||
private fun boundaryBitmap(horizontalBoundary: Boolean): Bitmap =
|
||||
Bitmap.createBitmap(SIZE, SIZE, Bitmap.Config.ARGB_8888).apply {
|
||||
for (y in 0 until SIZE) {
|
||||
for (x in 0 until SIZE) {
|
||||
val white = if (horizontalBoundary) x >= SIZE / 2 else y >= SIZE / 2
|
||||
setPixel(x, y, if (white) Color.WHITE else Color.BLACK)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun floatBuffer(values: FloatArray): FloatBuffer =
|
||||
ByteBuffer.allocateDirect(values.size * Float.SIZE_BYTES)
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.asFloatBuffer()
|
||||
.apply {
|
||||
put(values)
|
||||
position(0)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val SIZE = 64
|
||||
val VERTICES = floatArrayOf(-1f, -1f, 1f, -1f, -1f, 1f, 1f, 1f)
|
||||
val TEXTURE_COORDINATES = floatArrayOf(0f, 0f, 1f, 0f, 0f, 1f, 1f, 1f)
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.anthonyla.paperize.service.worker
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.work.WorkInfo
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.impl.WorkManagerImpl
|
||||
import com.anthonyla.paperize.core.ScreenType
|
||||
import com.anthonyla.paperize.core.WallpaperMode
|
||||
import com.anthonyla.paperize.core.constants.Constants
|
||||
import com.anthonyla.paperize.domain.model.ScheduleSettings
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class WallpaperSchedulerInstrumentedTest {
|
||||
private val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
private val workManager = WorkManager.getInstance(context) as WorkManagerImpl
|
||||
private val scheduler = WallpaperScheduler(context)
|
||||
private val targets = mapOf(
|
||||
ScreenType.HOME to Constants.WORK_NAME_HOME,
|
||||
ScreenType.LOCK to Constants.WORK_NAME_LOCK,
|
||||
ScreenType.BOTH to Constants.WORK_NAME_BOTH,
|
||||
ScreenType.LIVE to Constants.WORK_NAME_LIVE
|
||||
)
|
||||
|
||||
@Before
|
||||
@After
|
||||
fun clearTestSchedules() {
|
||||
targets.values.forEach { name ->
|
||||
workManager.cancelUniqueWork(name).result.get(10, TimeUnit.SECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun manualResetJobsRemainInTheirFirstPeriodUntilTheFullDelay() = runBlocking {
|
||||
val delayMillis = TimeUnit.MINUTES.toMillis(15)
|
||||
val jobs = targets.map { (screen, name) ->
|
||||
val before = System.currentTimeMillis()
|
||||
scheduler.scheduleWallpaperChange(screen, 15, resetInterval = true)
|
||||
val info = awaitEnqueued(name)
|
||||
assertTrue(info.nextScheduleTimeMillis >= before + delayMillis)
|
||||
info.id to before
|
||||
}
|
||||
|
||||
// Checking only the next countdown can miss an immediate first run: after that run,
|
||||
// periodic work also shows a full interval. Inspect the persisted first-period state.
|
||||
SystemClock.sleep(2_000)
|
||||
jobs.forEach { (id, before) ->
|
||||
val spec = requireNotNull(workManager.workDatabase.workSpecDao().getWorkSpec(id.toString()))
|
||||
assertEquals(delayMillis, spec.intervalDuration)
|
||||
assertEquals(0, spec.periodCount)
|
||||
assertEquals(WorkInfo.State.ENQUEUED, spec.state)
|
||||
assertTrue(spec.calculateNextRunTime() >= before + delayMillis)
|
||||
assertTrue(spec.calculateNextRunTime() <= System.currentTimeMillis() + delayMillis)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun settingsUpdatePreservesThePendingManualResetDelay() = runBlocking {
|
||||
scheduler.scheduleWallpaperChange(ScreenType.HOME, 60, resetInterval = true)
|
||||
val reset = awaitEnqueued(Constants.WORK_NAME_HOME)
|
||||
|
||||
scheduler.scheduleWallpaperChange(ScreenType.HOME, 60)
|
||||
|
||||
val updated = awaitEnqueued(Constants.WORK_NAME_HOME, minimumGeneration = reset.generation + 1)
|
||||
assertEquals(reset.id, updated.id)
|
||||
assertEquals(reset.nextScheduleTimeMillis, updated.nextScheduleTimeMillis)
|
||||
val spec = requireNotNull(workManager.workDatabase.workSpecDao().getWorkSpec(updated.id.toString()))
|
||||
assertEquals(0, spec.periodCount)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun repeatedHomeResetLeavesTheIndependentLockCountdownUntouched() = runBlocking {
|
||||
scheduler.scheduleWallpaperChange(ScreenType.HOME, 60, resetInterval = true)
|
||||
scheduler.scheduleWallpaperChange(ScreenType.LOCK, 90, resetInterval = true)
|
||||
val home = awaitEnqueued(Constants.WORK_NAME_HOME)
|
||||
val lock = awaitEnqueued(Constants.WORK_NAME_LOCK)
|
||||
val before = System.currentTimeMillis()
|
||||
|
||||
scheduler.resetAfterManualChange(
|
||||
ScreenType.HOME,
|
||||
ScheduleSettings(
|
||||
enableChanger = true,
|
||||
separateSchedules = true,
|
||||
homeEnabled = true,
|
||||
lockEnabled = true,
|
||||
homeAlbumId = "home",
|
||||
lockAlbumId = "lock",
|
||||
homeIntervalMinutes = 60,
|
||||
lockIntervalMinutes = 90
|
||||
),
|
||||
WallpaperMode.STATIC
|
||||
)
|
||||
|
||||
val newHome = awaitEnqueued(Constants.WORK_NAME_HOME, minimumGeneration = home.generation + 1)
|
||||
val sameLock = awaitEnqueued(Constants.WORK_NAME_LOCK)
|
||||
assertEquals(home.id, newHome.id)
|
||||
assertTrue(newHome.nextScheduleTimeMillis >= before + TimeUnit.MINUTES.toMillis(60))
|
||||
assertEquals(lock.id, sameLock.id)
|
||||
assertEquals(lock.nextScheduleTimeMillis, sameLock.nextScheduleTimeMillis)
|
||||
}
|
||||
|
||||
private suspend fun awaitEnqueued(
|
||||
name: String,
|
||||
minimumGeneration: Int = 0
|
||||
): WorkInfo =
|
||||
withTimeout(10_000) {
|
||||
workManager.getWorkInfosForUniqueWorkFlow(name).first { infos ->
|
||||
infos.any {
|
||||
it.state == WorkInfo.State.ENQUEUED &&
|
||||
it.generation >= minimumGeneration
|
||||
}
|
||||
}.single {
|
||||
it.state == WorkInfo.State.ENQUEUED &&
|
||||
it.generation >= minimumGeneration
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ object Constants {
|
||||
|
||||
// Services
|
||||
const val ACTION_CHANGE_WALLPAPER = "com.anthonyla.paperize.ACTION_CHANGE_WALLPAPER"
|
||||
const val ACTION_APPLY_SPECIFIC_WALLPAPER =
|
||||
"com.anthonyla.paperize.ACTION_APPLY_SPECIFIC_WALLPAPER"
|
||||
const val ACTION_REAPPLY_EFFECTS = "com.anthonyla.paperize.ACTION_REAPPLY_EFFECTS"
|
||||
const val ACTION_RELOAD_WALLPAPER = "com.anthonyla.paperize.ACTION_RELOAD_WALLPAPER"
|
||||
|
||||
@@ -35,6 +37,7 @@ object Constants {
|
||||
|
||||
// Intents
|
||||
const val EXTRA_SCREEN_TYPE = "screen_type"
|
||||
const val EXTRA_WALLPAPER_ID = "wallpaper_id"
|
||||
|
||||
// Wallpaper
|
||||
const val DEFAULT_BLUR_PERCENTAGE = 0
|
||||
@@ -49,6 +52,7 @@ object Constants {
|
||||
const val FLOW_SUBSCRIPTION_TIMEOUT_MS = 5000L
|
||||
|
||||
// Scheduling
|
||||
const val MIN_LIVE_INTERVAL_MINUTES = 1
|
||||
const val MIN_INTERVAL_MINUTES = 15
|
||||
const val MAX_INTERVAL_MINUTES = 43200 // 30 days in minutes
|
||||
const val DEFAULT_INTERVAL_MINUTES = 60
|
||||
|
||||
@@ -33,7 +33,7 @@ data class ScheduleSettings(
|
||||
fun validate(): ScheduleSettings = copy(
|
||||
homeIntervalMinutes = homeIntervalMinutes.coerceAtLeast(Constants.MIN_INTERVAL_MINUTES),
|
||||
lockIntervalMinutes = lockIntervalMinutes.coerceAtLeast(Constants.MIN_INTERVAL_MINUTES),
|
||||
liveIntervalMinutes = liveIntervalMinutes.coerceAtLeast(Constants.MIN_INTERVAL_MINUTES),
|
||||
liveIntervalMinutes = liveIntervalMinutes.coerceAtLeast(Constants.MIN_LIVE_INTERVAL_MINUTES),
|
||||
homeEffects = homeEffects.validate(),
|
||||
lockEffects = lockEffects.validate(),
|
||||
liveEffects = liveEffects.validate()
|
||||
@@ -80,3 +80,10 @@ data class ScheduleSettings(
|
||||
fun default() = ScheduleSettings()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WorkManager cannot run periodic jobs more often than every 15 minutes. Short live-wallpaper
|
||||
* intervals are therefore driven by the visible wallpaper engine and stop when it is hidden.
|
||||
*/
|
||||
fun usesVisibleLiveTimer(intervalMinutes: Int): Boolean =
|
||||
intervalMinutes in Constants.MIN_LIVE_INTERVAL_MINUTES until Constants.MIN_INTERVAL_MINUTES
|
||||
@@ -181,12 +181,25 @@ class ChangeWallpaperUseCase @Inject constructor(
|
||||
suspend fun complete(
|
||||
prepared: PreparedWallpaper,
|
||||
screenType: ScreenType = prepared.screenType
|
||||
) = completeSpecific(
|
||||
albumId = prepared.albumId,
|
||||
screenType = screenType,
|
||||
wallpaperId = prepared.wallpaperId,
|
||||
shuffle = prepared.shuffle
|
||||
)
|
||||
|
||||
/** Record a user-selected wallpaper and remove that exact item from the next-change queue. */
|
||||
suspend fun completeSpecific(
|
||||
albumId: String,
|
||||
screenType: ScreenType,
|
||||
wallpaperId: String,
|
||||
shuffle: Boolean
|
||||
) {
|
||||
try {
|
||||
wallpaperRepository.setCurrentWallpaper(
|
||||
prepared.albumId,
|
||||
albumId,
|
||||
screenType,
|
||||
prepared.wallpaperId
|
||||
wallpaperId
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Applied wallpaper could not be recorded as current", e)
|
||||
@@ -194,20 +207,20 @@ class ChangeWallpaperUseCase @Inject constructor(
|
||||
}
|
||||
|
||||
try {
|
||||
if (wallpaperRepository.getNextWallpaperInQueue(prepared.albumId, screenType) == null) {
|
||||
if (wallpaperRepository.getNextWallpaperInQueue(albumId, screenType) == null) {
|
||||
wallpaperRepository.buildWallpaperQueue(
|
||||
prepared.albumId,
|
||||
albumId,
|
||||
screenType,
|
||||
prepared.shuffle
|
||||
shuffle
|
||||
)
|
||||
}
|
||||
// Build first when this is the first synchronized use of a screen queue, then remove
|
||||
// the exact applied item. This prevents the just-applied wallpaper from being
|
||||
// reintroduced at the head of a freshly built queue.
|
||||
wallpaperRepository.removeWallpaperFromQueue(
|
||||
prepared.albumId,
|
||||
albumId,
|
||||
screenType,
|
||||
prepared.wallpaperId
|
||||
wallpaperId
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Queue sync failed; it will rebuild on the next change", e)
|
||||
|
||||
+8
-4
@@ -142,8 +142,10 @@ fun NavigationGraph(
|
||||
onNavigateToFolder = { folderId ->
|
||||
navController.navigate(FolderRoute(folderId))
|
||||
},
|
||||
onNavigateToWallpaperView = { wallpaperUri, wallpaperName ->
|
||||
navController.navigate(WallpaperViewRoute(wallpaperUri, wallpaperName))
|
||||
onNavigateToWallpaperView = { wallpaperId, wallpaperUri, wallpaperName ->
|
||||
navController.navigate(
|
||||
WallpaperViewRoute(wallpaperId, wallpaperUri, wallpaperName)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -172,8 +174,10 @@ fun NavigationGraph(
|
||||
backStackEntry.toRoute<FolderRoute>()
|
||||
FolderViewScreen(
|
||||
onBackClick = { navController.popBackStack() },
|
||||
onNavigateToWallpaperView = { wallpaperUri, wallpaperName ->
|
||||
navController.navigate(WallpaperViewRoute(wallpaperUri, wallpaperName))
|
||||
onNavigateToWallpaperView = { wallpaperId, wallpaperUri, wallpaperName ->
|
||||
navController.navigate(
|
||||
WallpaperViewRoute(wallpaperId, wallpaperUri, wallpaperName)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,11 @@ data class AlbumRoute(val albumId: String)
|
||||
data class FolderRoute(val folderId: String)
|
||||
|
||||
@Serializable
|
||||
data class WallpaperViewRoute(val wallpaperUri: String, val wallpaperName: String)
|
||||
data class WallpaperViewRoute(
|
||||
val wallpaperId: String,
|
||||
val wallpaperUri: String,
|
||||
val wallpaperName: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SortRoute(val albumId: String)
|
||||
|
||||
+6
-2
@@ -48,7 +48,7 @@ import com.anthonyla.paperize.presentation.theme.AppSpacing
|
||||
fun AlbumViewScreen(
|
||||
onBackClick: () -> Unit,
|
||||
onNavigateToFolder: (String) -> Unit,
|
||||
onNavigateToWallpaperView: (String, String) -> Unit,
|
||||
onNavigateToWallpaperView: (String, String, String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: AlbumViewViewModel = hiltViewModel()
|
||||
) {
|
||||
@@ -221,7 +221,11 @@ fun AlbumViewScreen(
|
||||
if (isSelectionMode) {
|
||||
viewModel.toggleWallpaperSelection(wallpaper.id)
|
||||
} else {
|
||||
onNavigateToWallpaperView(wallpaper.uri, wallpaper.fileName)
|
||||
onNavigateToWallpaperView(
|
||||
wallpaper.id,
|
||||
wallpaper.uri,
|
||||
wallpaper.fileName
|
||||
)
|
||||
}
|
||||
},
|
||||
onLongClick = {
|
||||
|
||||
+12
-8
@@ -13,8 +13,9 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.SheetValue
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import androidx.compose.material3.rememberBottomSheetState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@@ -41,7 +42,10 @@ fun SortBottomSheet(
|
||||
onDismiss: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||
val sheetState = rememberBottomSheetState(
|
||||
initialValue = SheetValue.Hidden,
|
||||
enabledValues = setOf(SheetValue.Hidden, SheetValue.Expanded)
|
||||
)
|
||||
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = onDismiss,
|
||||
@@ -59,7 +63,7 @@ fun SortBottomSheet(
|
||||
|
||||
// Name Ascending
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.sort_name_asc)) },
|
||||
content = { Text(stringResource(R.string.sort_name_asc)) },
|
||||
leadingContent = {
|
||||
Icon(Icons.Default.SortByAlpha, contentDescription = null)
|
||||
},
|
||||
@@ -71,7 +75,7 @@ fun SortBottomSheet(
|
||||
|
||||
// Name Descending
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.sort_name_desc)) },
|
||||
content = { Text(stringResource(R.string.sort_name_desc)) },
|
||||
leadingContent = {
|
||||
Icon(Icons.Default.SortByAlpha, contentDescription = null)
|
||||
},
|
||||
@@ -85,7 +89,7 @@ fun SortBottomSheet(
|
||||
|
||||
// Date Added Ascending
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.sort_date_added_asc)) },
|
||||
content = { Text(stringResource(R.string.sort_date_added_asc)) },
|
||||
leadingContent = {
|
||||
Icon(Icons.Default.AccessTime, contentDescription = null)
|
||||
},
|
||||
@@ -97,7 +101,7 @@ fun SortBottomSheet(
|
||||
|
||||
// Date Added Descending
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.sort_date_added_desc)) },
|
||||
content = { Text(stringResource(R.string.sort_date_added_desc)) },
|
||||
leadingContent = {
|
||||
Icon(Icons.Default.AccessTime, contentDescription = null)
|
||||
},
|
||||
@@ -111,7 +115,7 @@ fun SortBottomSheet(
|
||||
|
||||
// Date Modified Ascending
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.sort_date_modified_asc)) },
|
||||
content = { Text(stringResource(R.string.sort_date_modified_asc)) },
|
||||
leadingContent = {
|
||||
Icon(Icons.Default.AccessTime, contentDescription = null)
|
||||
},
|
||||
@@ -123,7 +127,7 @@ fun SortBottomSheet(
|
||||
|
||||
// Date Modified Descending
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.sort_date_modified_desc)) },
|
||||
content = { Text(stringResource(R.string.sort_date_modified_desc)) },
|
||||
leadingContent = {
|
||||
Icon(Icons.Default.AccessTime, contentDescription = null)
|
||||
},
|
||||
|
||||
+8
-2
@@ -34,7 +34,7 @@ import com.anthonyla.paperize.presentation.theme.AppSpacing
|
||||
@Composable
|
||||
fun FolderViewScreen(
|
||||
onBackClick: () -> Unit,
|
||||
onNavigateToWallpaperView: (String, String) -> Unit,
|
||||
onNavigateToWallpaperView: (String, String, String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: FolderViewViewModel = hiltViewModel()
|
||||
) {
|
||||
@@ -84,7 +84,13 @@ fun FolderViewScreen(
|
||||
wallpaperUri = wallpaper.uri,
|
||||
isSelected = false,
|
||||
isSelectionMode = false,
|
||||
onClick = { onNavigateToWallpaperView(wallpaper.uri, wallpaper.fileName) },
|
||||
onClick = {
|
||||
onNavigateToWallpaperView(
|
||||
wallpaper.id,
|
||||
wallpaper.uri,
|
||||
wallpaper.fileName
|
||||
)
|
||||
},
|
||||
onLongClick = { /* No selection in folder view */ },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
||||
@@ -512,10 +512,15 @@ class HomeViewModel @Inject constructor(
|
||||
if (wallpaperMode.value == com.anthonyla.paperize.core.WallpaperMode.LIVE) {
|
||||
// LIVE mode: schedule live wallpaper changes
|
||||
if (settings.liveAlbumId != null && settings.liveIntervalMinutes > 0) {
|
||||
wallpaperScheduler.scheduleWallpaperChange(
|
||||
ScreenType.LIVE,
|
||||
settings.liveIntervalMinutes
|
||||
)
|
||||
if (settings.liveIntervalMinutes >= Constants.MIN_INTERVAL_MINUTES) {
|
||||
wallpaperScheduler.scheduleWallpaperChange(
|
||||
ScreenType.LIVE,
|
||||
settings.liveIntervalMinutes
|
||||
)
|
||||
} else {
|
||||
// The visible live-wallpaper engine owns sub-15-minute intervals.
|
||||
wallpaperScheduler.cancelWallpaperChange(ScreenType.LIVE)
|
||||
}
|
||||
wallpaperScheduler.scheduleAlbumRefresh()
|
||||
} else {
|
||||
wallpaperScheduler.cancelWallpaperChange(ScreenType.LIVE)
|
||||
|
||||
+1
-1
@@ -332,7 +332,7 @@ fun SortViewScreen(
|
||||
.clip(AppShapes.imageShape)
|
||||
)
|
||||
},
|
||||
headlineContent = {
|
||||
content = {
|
||||
Text(
|
||||
text = currentFolder.name,
|
||||
maxLines = 2,
|
||||
|
||||
+7
@@ -542,12 +542,19 @@ fun WallpaperScreen(
|
||||
TimeIntervalPicker(
|
||||
title = stringResource(R.string.interval_text),
|
||||
minutes = scheduleSettings.liveIntervalMinutes,
|
||||
minimumMinutes = Constants.MIN_LIVE_INTERVAL_MINUTES,
|
||||
onMinutesChange = { minutes ->
|
||||
onUpdateScheduleSettings(
|
||||
scheduleSettings.copy(liveIntervalMinutes = minutes)
|
||||
)
|
||||
}
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.live_short_interval_note),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(horizontal = AppSpacing.large)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -28,8 +28,9 @@ import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.SheetValue
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import androidx.compose.material3.rememberBottomSheetState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -63,7 +64,7 @@ fun AlbumSelectionBottomSheet(
|
||||
onAlbumSelect: (AlbumSummary) -> Unit,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
val sheetState = rememberModalBottomSheetState()
|
||||
val sheetState = rememberBottomSheetState(initialValue = SheetValue.Hidden)
|
||||
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = onDismiss,
|
||||
|
||||
+5
-3
@@ -14,6 +14,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableLongStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
@@ -39,7 +40,8 @@ fun TimeIntervalPicker(
|
||||
title: String,
|
||||
minutes: Int,
|
||||
onMinutesChange: (Int) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
modifier: Modifier = Modifier,
|
||||
minimumMinutes: Int = Constants.MIN_INTERVAL_MINUTES
|
||||
) {
|
||||
// Decompose incoming minutes value into days, hours, minutes
|
||||
val initialDays = minutes / Constants.MINUTES_PER_DAY
|
||||
@@ -57,7 +59,7 @@ fun TimeIntervalPicker(
|
||||
var minuteInput by remember(minutes) { mutableStateOf(initialMins.toString()) }
|
||||
|
||||
// Debounce state - tracks when user last made a change; reset when external `minutes` prop changes
|
||||
var lastChangeTimestamp by remember(minutes) { mutableStateOf(0L) }
|
||||
var lastChangeTimestamp by remember(minutes) { mutableLongStateOf(0L) }
|
||||
|
||||
// Debounced update - only fires after user stops typing
|
||||
LaunchedEffect(dayValue, hourValue, minuteValue, lastChangeTimestamp) {
|
||||
@@ -65,7 +67,7 @@ fun TimeIntervalPicker(
|
||||
delay(Constants.DEBOUNCE_DELAY_MS)
|
||||
val total = (dayValue * Constants.MINUTES_PER_DAY) + (hourValue * Constants.MINUTES_PER_HOUR) + minuteValue
|
||||
// Clamp between minimum and maximum interval
|
||||
val clamped = min(max(total, Constants.MIN_INTERVAL_MINUTES), Constants.MAX_INTERVAL_MINUTES)
|
||||
val clamped = min(max(total, minimumMinutes), Constants.MAX_INTERVAL_MINUTES)
|
||||
onMinutesChange(clamped)
|
||||
}
|
||||
}
|
||||
|
||||
+69
-2
@@ -3,11 +3,14 @@ package com.anthonyla.paperize.presentation.screens.wallpaper_view
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredSize
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.BottomAppBar
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
@@ -15,19 +18,29 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import coil3.compose.AsyncImage
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.core.ScreenType
|
||||
import com.anthonyla.paperize.core.WallpaperMode
|
||||
import com.anthonyla.paperize.presentation.theme.AppSpacing
|
||||
import net.engawapg.lib.zoomable.rememberZoomState
|
||||
import net.engawapg.lib.zoomable.zoomable
|
||||
@@ -38,9 +51,12 @@ fun WallpaperViewScreen(
|
||||
wallpaperUri: String,
|
||||
wallpaperName: String,
|
||||
onBackClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: WallpaperViewViewModel = hiltViewModel()
|
||||
) {
|
||||
val zoomState = rememberZoomState()
|
||||
val wallpaperMode by viewModel.wallpaperMode.collectAsStateWithLifecycle()
|
||||
var showApplyDialog by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
Scaffold(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
@@ -79,7 +95,27 @@ fun WallpaperViewScreen(
|
||||
bottomBar = {
|
||||
BottomAppBar(
|
||||
containerColor = Color.Transparent,
|
||||
actions = {}
|
||||
actions = {
|
||||
if (wallpaperMode == WallpaperMode.STATIC) {
|
||||
Button(
|
||||
onClick = { showApplyDialog = true },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = AppSpacing.large)
|
||||
) {
|
||||
Text(stringResource(R.string.set_wallpaper))
|
||||
}
|
||||
} else {
|
||||
Text(
|
||||
text = stringResource(R.string.individual_wallpaper_static_only),
|
||||
color = MaterialTheme.colorScheme.surfaceBright,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = AppSpacing.large)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
) { padding ->
|
||||
@@ -103,4 +139,35 @@ fun WallpaperViewScreen(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showApplyDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showApplyDialog = false },
|
||||
title = { Text(stringResource(R.string.set_wallpaper)) },
|
||||
text = {
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
listOf(
|
||||
ScreenType.HOME to R.string.home_screen_btn,
|
||||
ScreenType.LOCK to R.string.lock_screen_btn,
|
||||
ScreenType.BOTH to R.string.home_and_lock_screens
|
||||
).forEach { (screenType, label) ->
|
||||
TextButton(
|
||||
onClick = {
|
||||
showApplyDialog = false
|
||||
viewModel.applyTo(screenType)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(stringResource(label))
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = { showApplyDialog = false }) {
|
||||
Text(stringResource(R.string.cancel))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.anthonyla.paperize.presentation.screens.wallpaper_view
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.SavedStateHandle
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.toRoute
|
||||
import com.anthonyla.paperize.core.ScreenType
|
||||
import com.anthonyla.paperize.core.WallpaperMode
|
||||
import com.anthonyla.paperize.core.constants.Constants
|
||||
import com.anthonyla.paperize.domain.repository.SettingsRepository
|
||||
import com.anthonyla.paperize.presentation.common.navigation.WallpaperViewRoute
|
||||
import com.anthonyla.paperize.service.wallpaper.WallpaperChangeService
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
|
||||
@HiltViewModel
|
||||
class WallpaperViewViewModel @Inject constructor(
|
||||
savedStateHandle: SavedStateHandle,
|
||||
@param:ApplicationContext private val context: Context,
|
||||
settingsRepository: SettingsRepository
|
||||
) : ViewModel() {
|
||||
private val route = savedStateHandle.toRoute<WallpaperViewRoute>()
|
||||
|
||||
val wallpaperMode = settingsRepository.getWallpaperModeFlow().stateIn(
|
||||
scope = viewModelScope,
|
||||
started = SharingStarted.WhileSubscribed(Constants.FLOW_SUBSCRIPTION_TIMEOUT_MS),
|
||||
initialValue = WallpaperMode.STATIC
|
||||
)
|
||||
|
||||
fun applyTo(screenType: ScreenType) {
|
||||
require(screenType != ScreenType.LIVE)
|
||||
context.startForegroundService(
|
||||
Intent(context, WallpaperChangeService::class.java).apply {
|
||||
action = WallpaperChangeService.ACTION_APPLY_SPECIFIC_WALLPAPER
|
||||
putExtra(WallpaperChangeService.EXTRA_WALLPAPER_ID, route.wallpaperId)
|
||||
putExtra(WallpaperChangeService.EXTRA_SCREEN_TYPE, screenType.name)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.anthonyla.paperize.core.ScreenType
|
||||
import com.anthonyla.paperize.core.constants.Constants
|
||||
import com.anthonyla.paperize.domain.repository.SettingsRepository
|
||||
import com.anthonyla.paperize.service.worker.WallpaperScheduler
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
@@ -54,10 +55,14 @@ class BootReceiver : BroadcastReceiver() {
|
||||
if (wallpaperMode == com.anthonyla.paperize.core.WallpaperMode.LIVE) {
|
||||
// LIVE mode: schedule live wallpaper changes
|
||||
if (settings.liveAlbumId != null && settings.liveIntervalMinutes > 0) {
|
||||
wallpaperScheduler.scheduleWallpaperChange(
|
||||
ScreenType.LIVE,
|
||||
settings.liveIntervalMinutes
|
||||
)
|
||||
if (settings.liveIntervalMinutes >= Constants.MIN_INTERVAL_MINUTES) {
|
||||
wallpaperScheduler.scheduleWallpaperChange(
|
||||
ScreenType.LIVE,
|
||||
settings.liveIntervalMinutes
|
||||
)
|
||||
} else {
|
||||
wallpaperScheduler.cancelWallpaperChange(ScreenType.LIVE)
|
||||
}
|
||||
wallpaperScheduler.scheduleAlbumRefresh()
|
||||
Log.d(TAG, "Live wallpaper changes scheduled on boot")
|
||||
} else {
|
||||
|
||||
+49
@@ -12,6 +12,9 @@ import androidx.savedstate.SavedStateRegistryController
|
||||
import androidx.savedstate.SavedStateRegistryOwner
|
||||
import com.anthonyla.paperize.core.ScreenType
|
||||
import com.anthonyla.paperize.core.ScalingType
|
||||
import com.anthonyla.paperize.core.WallpaperMode
|
||||
import com.anthonyla.paperize.domain.model.ScheduleSettings
|
||||
import com.anthonyla.paperize.domain.model.usesVisibleLiveTimer
|
||||
import com.anthonyla.paperize.domain.repository.SettingsRepository
|
||||
import com.anthonyla.paperize.domain.repository.WallpaperRepository
|
||||
import com.anthonyla.paperize.service.livewallpaper.gl.GLWallpaperService
|
||||
@@ -27,11 +30,14 @@ import dagger.hilt.android.EntryPointAccessors
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.withContext
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
@@ -106,6 +112,10 @@ class PaperizeLiveWallpaperService : GLWallpaperService(), LifecycleOwner {
|
||||
@Volatile private var currentWallpaper: Wallpaper? = null
|
||||
private var observedScalingType: ScalingType? = null
|
||||
private var hasShownParallaxWarning = false
|
||||
private var engineVisible = false
|
||||
private var latestSettings = ScheduleSettings.default()
|
||||
private var latestWallpaperMode = WallpaperMode.STATIC
|
||||
private var liveIntervalJob: Job? = null
|
||||
|
||||
private val gestureDetector = GestureDetector(
|
||||
this@PaperizeLiveWallpaperService,
|
||||
@@ -122,6 +132,7 @@ class PaperizeLiveWallpaperService : GLWallpaperService(), LifecycleOwner {
|
||||
if (intent?.action == Constants.ACTION_RELOAD_WALLPAPER) {
|
||||
Log.d(TAG, "Received reload broadcast")
|
||||
renderController.reloadCurrentArtwork(com.anthonyla.paperize.service.livewallpaper.renderer.ReloadImmediate)
|
||||
restartLiveIntervalTimer()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,6 +291,15 @@ class PaperizeLiveWallpaperService : GLWallpaperService(), LifecycleOwner {
|
||||
}.catch { e ->
|
||||
Log.e(TAG, "Error observing settings", e)
|
||||
}.collect { (settings, mode) ->
|
||||
val timerConfigurationChanged =
|
||||
latestWallpaperMode != mode ||
|
||||
latestSettings.enableChanger != settings.enableChanger ||
|
||||
latestSettings.liveAlbumId != settings.liveAlbumId ||
|
||||
latestSettings.liveIntervalMinutes != settings.liveIntervalMinutes
|
||||
latestSettings = settings
|
||||
latestWallpaperMode = mode
|
||||
if (timerConfigurationChanged) restartLiveIntervalTimer()
|
||||
|
||||
// Only process settings in LIVE mode
|
||||
// In STATIC mode, the static wallpaper worker handles HOME/LOCK screens
|
||||
if (mode != com.anthonyla.paperize.core.WallpaperMode.LIVE) {
|
||||
@@ -344,12 +364,14 @@ class PaperizeLiveWallpaperService : GLWallpaperService(), LifecycleOwner {
|
||||
}
|
||||
|
||||
override fun onVisibilityChanged(visible: Boolean) {
|
||||
engineVisible = visible
|
||||
renderController.visible = visible
|
||||
if (visible) {
|
||||
// Re-evaluate draw-time effects such as adaptive brightness after
|
||||
// configuration changes while the wallpaper was hidden.
|
||||
requestRender()
|
||||
}
|
||||
restartLiveIntervalTimer()
|
||||
super.onVisibilityChanged(visible)
|
||||
}
|
||||
|
||||
@@ -412,6 +434,7 @@ class PaperizeLiveWallpaperService : GLWallpaperService(), LifecycleOwner {
|
||||
|
||||
if (doubleTapEnabled) {
|
||||
renderController.reloadCurrentArtwork(com.anthonyla.paperize.service.livewallpaper.renderer.ReloadImmediate)
|
||||
restartLiveIntervalTimer()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -426,5 +449,31 @@ class PaperizeLiveWallpaperService : GLWallpaperService(), LifecycleOwner {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun restartLiveIntervalTimer() {
|
||||
liveIntervalJob?.cancel()
|
||||
liveIntervalJob = null
|
||||
|
||||
val intervalMinutes = latestSettings.liveIntervalMinutes
|
||||
val shouldRun =
|
||||
engineVisible &&
|
||||
!isPreview &&
|
||||
latestWallpaperMode == WallpaperMode.LIVE &&
|
||||
latestSettings.enableChanger &&
|
||||
latestSettings.liveAlbumId != null &&
|
||||
usesVisibleLiveTimer(intervalMinutes)
|
||||
if (!shouldRun) return
|
||||
|
||||
liveIntervalJob = engineScope.launch {
|
||||
val intervalMillis = intervalMinutes.toLong() * 60_000L
|
||||
while (isActive) {
|
||||
delay(intervalMillis)
|
||||
Log.d(TAG, "Visible live interval elapsed; changing wallpaper")
|
||||
renderController.reloadCurrentArtwork(
|
||||
com.anthonyla.paperize.service.livewallpaper.renderer.ReloadImmediate
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,64 +2,20 @@ package com.anthonyla.paperize.service.tile
|
||||
|
||||
import android.content.Intent
|
||||
import android.service.quicksettings.TileService
|
||||
import android.util.Log
|
||||
import com.anthonyla.paperize.core.ScreenType
|
||||
import com.anthonyla.paperize.core.WallpaperMode
|
||||
import com.anthonyla.paperize.core.constants.Constants
|
||||
import com.anthonyla.paperize.domain.repository.SettingsRepository
|
||||
import com.anthonyla.paperize.service.wallpaper.WallpaperChangeService
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Quick Settings Tile for changing wallpaper
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
class WallpaperTileService : TileService() {
|
||||
|
||||
@Inject
|
||||
lateinit var settingsRepository: SettingsRepository
|
||||
|
||||
private val serviceScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
companion object {
|
||||
private const val TAG = "WallpaperTileService"
|
||||
}
|
||||
|
||||
override fun onClick() {
|
||||
super.onClick()
|
||||
|
||||
serviceScope.launch {
|
||||
try {
|
||||
val mode = settingsRepository.getWallpaperMode()
|
||||
|
||||
if (mode == WallpaperMode.LIVE) {
|
||||
// Send broadcast to trigger live wallpaper reload
|
||||
val intent = Intent(Constants.ACTION_RELOAD_WALLPAPER)
|
||||
intent.setPackage(packageName)
|
||||
sendBroadcast(intent)
|
||||
} else {
|
||||
// Start wallpaper change service for static wallpaper
|
||||
// Use BOTH to ensure synchronized change if configured, or both if not
|
||||
val intent = Intent(this@WallpaperTileService, WallpaperChangeService::class.java).apply {
|
||||
action = Constants.ACTION_CHANGE_WALLPAPER
|
||||
putExtra(Constants.EXTRA_SCREEN_TYPE, ScreenType.BOTH.name)
|
||||
}
|
||||
startForegroundService(intent)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Error handling tile click", e)
|
||||
startForegroundService(
|
||||
Intent(this, WallpaperChangeService::class.java).apply {
|
||||
action = WallpaperChangeService.ACTION_CHANGE_WALLPAPER_AUTO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
serviceScope.cancel()
|
||||
)
|
||||
}
|
||||
}
|
||||
+172
-17
@@ -7,6 +7,7 @@ import android.app.Service
|
||||
import android.app.WallpaperManager
|
||||
import android.content.Intent
|
||||
import android.content.pm.ServiceInfo
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
@@ -21,10 +22,12 @@ import com.anthonyla.paperize.core.util.setBitmapChecked
|
||||
import com.anthonyla.paperize.domain.model.PreparedWallpaper
|
||||
import com.anthonyla.paperize.domain.model.ScheduleSettings
|
||||
import com.anthonyla.paperize.domain.repository.SettingsRepository
|
||||
import com.anthonyla.paperize.domain.repository.WallpaperRepository
|
||||
import com.anthonyla.paperize.domain.usecase.ChangeWallpaperUseCase
|
||||
import com.anthonyla.paperize.domain.usecase.ReapplyEffectsUseCase
|
||||
import com.anthonyla.paperize.presentation.MainActivity
|
||||
import com.anthonyla.paperize.service.WallpaperChangeLock
|
||||
import com.anthonyla.paperize.service.worker.WallpaperScheduler
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -44,6 +47,8 @@ class WallpaperChangeService : Service() {
|
||||
@Inject lateinit var reapplyEffectsUseCase: ReapplyEffectsUseCase
|
||||
@Inject lateinit var settingsRepository: SettingsRepository
|
||||
@Inject lateinit var wallpaperChangeLock: WallpaperChangeLock
|
||||
@Inject lateinit var wallpaperScheduler: WallpaperScheduler
|
||||
@Inject lateinit var wallpaperRepository: WallpaperRepository
|
||||
|
||||
private val serviceScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
private lateinit var wallpaperManager: WallpaperManager
|
||||
@@ -74,6 +79,11 @@ class WallpaperChangeService : Service() {
|
||||
ACTION_CHANGE_WALLPAPER -> handleChangeWallpaper(screenType, startId)
|
||||
ACTION_CHANGE_WALLPAPER_AUTO ->
|
||||
handleChangeWallpaper(screenType, startId, respectWallpaperMode = true)
|
||||
ACTION_APPLY_SPECIFIC_WALLPAPER -> handleApplySpecificWallpaper(
|
||||
wallpaperId = intent.getStringExtra(EXTRA_WALLPAPER_ID),
|
||||
screenType = screenType,
|
||||
startId = startId
|
||||
)
|
||||
ACTION_REAPPLY_EFFECTS -> handleReapplyEffects(screenType, startId)
|
||||
else -> {
|
||||
Log.w(TAG, "Unknown action: ${intent?.action}")
|
||||
@@ -91,19 +101,24 @@ class WallpaperChangeService : Service() {
|
||||
serviceScope.launch {
|
||||
wallpaperChangeLock.mutex.withLock {
|
||||
try {
|
||||
val wallpaperMode = settingsRepository.getWallpaperMode()
|
||||
val effectiveScreenType =
|
||||
if (
|
||||
respectWallpaperMode &&
|
||||
settingsRepository.getWallpaperMode() == WallpaperMode.LIVE
|
||||
wallpaperMode == WallpaperMode.LIVE
|
||||
) {
|
||||
ScreenType.LIVE
|
||||
} else {
|
||||
screenType
|
||||
}
|
||||
changeWallpaper(
|
||||
effectiveScreenType,
|
||||
settingsRepository.getScheduleSettings()
|
||||
)
|
||||
val settings = settingsRepository.getScheduleSettings()
|
||||
if (changeWallpaper(effectiveScreenType, settings)) {
|
||||
wallpaperScheduler.resetAfterManualChange(
|
||||
effectiveScreenType,
|
||||
settings,
|
||||
wallpaperMode
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Error changing wallpaper", e)
|
||||
showErrorNotification(
|
||||
@@ -121,22 +136,23 @@ class WallpaperChangeService : Service() {
|
||||
private suspend fun changeWallpaper(
|
||||
screenType: ScreenType,
|
||||
settings: ScheduleSettings
|
||||
) {
|
||||
): Boolean =
|
||||
when (screenType) {
|
||||
ScreenType.LIVE -> {
|
||||
sendBroadcast(
|
||||
Intent(Constants.ACTION_RELOAD_WALLPAPER).setPackage(packageName)
|
||||
)
|
||||
Log.d(TAG, "Requested immediate live wallpaper reload")
|
||||
true
|
||||
}
|
||||
|
||||
ScreenType.HOME -> settings.homeAlbumId?.let {
|
||||
changeSingle(it, ScreenType.HOME)
|
||||
} ?: Log.w(TAG, "No home album selected")
|
||||
} ?: false.also { Log.w(TAG, "No home album selected") }
|
||||
|
||||
ScreenType.LOCK -> settings.lockAlbumId?.let {
|
||||
changeSingle(it, ScreenType.LOCK)
|
||||
} ?: Log.w(TAG, "No lock album selected")
|
||||
} ?: false.also { Log.w(TAG, "No lock album selected") }
|
||||
|
||||
ScreenType.BOTH -> {
|
||||
val homeAlbumId = settings.homeAlbumId
|
||||
@@ -148,19 +164,20 @@ class WallpaperChangeService : Service() {
|
||||
) {
|
||||
changeSynchronized(homeAlbumId, settings)
|
||||
} else {
|
||||
homeAlbumId?.let { changeSingle(it, ScreenType.HOME) }
|
||||
var changed = false
|
||||
homeAlbumId?.let { changed = changeSingle(it, ScreenType.HOME) || changed }
|
||||
?: Log.w(TAG, "No home album selected")
|
||||
lockAlbumId?.let { changeSingle(it, ScreenType.LOCK) }
|
||||
lockAlbumId?.let { changed = changeSingle(it, ScreenType.LOCK) || changed }
|
||||
?: Log.w(TAG, "No lock album selected")
|
||||
changed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun changeSynchronized(
|
||||
albumId: String,
|
||||
settings: ScheduleSettings
|
||||
) {
|
||||
): Boolean =
|
||||
when (val result = changeWallpaperUseCase(albumId, ScreenType.HOME)) {
|
||||
is PaperizeResult.Success -> {
|
||||
val prepared = result.data
|
||||
@@ -209,11 +226,13 @@ class WallpaperChangeService : Service() {
|
||||
PaperizeResult.Loading -> error("Unexpected loading result")
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
is PaperizeResult.Error -> {
|
||||
if (result.exception is EmptyAlbumException) {
|
||||
handleEmptyAlbumError(ScreenType.BOTH)
|
||||
false
|
||||
} else {
|
||||
throw asException(result.exception)
|
||||
}
|
||||
@@ -221,12 +240,11 @@ class WallpaperChangeService : Service() {
|
||||
|
||||
PaperizeResult.Loading -> error("Unexpected loading result")
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun changeSingle(
|
||||
albumId: String,
|
||||
screenType: ScreenType
|
||||
) {
|
||||
): Boolean =
|
||||
when (val result = changeWallpaperUseCase(albumId, screenType)) {
|
||||
is PaperizeResult.Success -> {
|
||||
val which = when (screenType) {
|
||||
@@ -236,11 +254,13 @@ class WallpaperChangeService : Service() {
|
||||
}
|
||||
applyPrepared(result.data, which, listOf(screenType))
|
||||
Log.d(TAG, "$screenType wallpaper changed successfully")
|
||||
true
|
||||
}
|
||||
|
||||
is PaperizeResult.Error -> {
|
||||
if (result.exception is EmptyAlbumException) {
|
||||
handleEmptyAlbumError(screenType)
|
||||
false
|
||||
} else {
|
||||
throw asException(result.exception)
|
||||
}
|
||||
@@ -248,7 +268,6 @@ class WallpaperChangeService : Service() {
|
||||
|
||||
PaperizeResult.Loading -> error("Unexpected loading result")
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun applyPrepared(
|
||||
prepared: PreparedWallpaper,
|
||||
@@ -272,6 +291,140 @@ class WallpaperChangeService : Service() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleApplySpecificWallpaper(
|
||||
wallpaperId: String?,
|
||||
screenType: ScreenType,
|
||||
startId: Int
|
||||
) {
|
||||
serviceScope.launch {
|
||||
wallpaperChangeLock.mutex.withLock {
|
||||
try {
|
||||
require(!wallpaperId.isNullOrBlank()) { getString(R.string.wallpaper_not_found) }
|
||||
require(screenType != ScreenType.LIVE) { getString(R.string.static_mode_required) }
|
||||
val wallpaperMode = settingsRepository.getWallpaperMode()
|
||||
require(wallpaperMode == WallpaperMode.STATIC) {
|
||||
getString(R.string.static_mode_required)
|
||||
}
|
||||
val wallpaper = wallpaperRepository.getWallpaperById(wallpaperId)
|
||||
?: error(getString(R.string.wallpaper_not_found))
|
||||
val settings = settingsRepository.getScheduleSettings()
|
||||
|
||||
applySpecificWallpaper(
|
||||
albumId = wallpaper.albumId,
|
||||
wallpaperId = wallpaper.id,
|
||||
screenType = screenType,
|
||||
settings = settings
|
||||
)
|
||||
wallpaperScheduler.resetAfterManualChange(
|
||||
screenType = screenType,
|
||||
settings = settings,
|
||||
wallpaperMode = wallpaperMode
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Error applying selected wallpaper", e)
|
||||
showErrorNotification(
|
||||
getString(R.string.app_name),
|
||||
e.localizedMessage ?: getString(R.string.error_no_valid_wallpaper_after_retries)
|
||||
)
|
||||
} finally {
|
||||
stopSelf(startId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun applySpecificWallpaper(
|
||||
albumId: String,
|
||||
wallpaperId: String,
|
||||
screenType: ScreenType,
|
||||
settings: ScheduleSettings
|
||||
) {
|
||||
when (screenType) {
|
||||
ScreenType.HOME, ScreenType.LOCK -> applySpecificSingle(
|
||||
albumId,
|
||||
wallpaperId,
|
||||
screenType,
|
||||
settings.shuffleEnabled
|
||||
)
|
||||
|
||||
ScreenType.BOTH -> {
|
||||
val samePresentation =
|
||||
settings.homeEffects == settings.lockEffects &&
|
||||
settings.homeScalingType == settings.lockScalingType &&
|
||||
!settings.homeScrollingEnabled
|
||||
if (samePresentation) {
|
||||
val bitmap = renderSpecific(albumId, wallpaperId, ScreenType.HOME)
|
||||
try {
|
||||
wallpaperManager.setBitmapChecked(
|
||||
bitmap,
|
||||
WallpaperManager.FLAG_SYSTEM or WallpaperManager.FLAG_LOCK
|
||||
)
|
||||
changeWallpaperUseCase.completeSpecific(
|
||||
albumId,
|
||||
ScreenType.HOME,
|
||||
wallpaperId,
|
||||
settings.shuffleEnabled
|
||||
)
|
||||
changeWallpaperUseCase.completeSpecific(
|
||||
albumId,
|
||||
ScreenType.LOCK,
|
||||
wallpaperId,
|
||||
settings.shuffleEnabled
|
||||
)
|
||||
} finally {
|
||||
bitmap.recycle()
|
||||
}
|
||||
} else {
|
||||
applySpecificSingle(
|
||||
albumId,
|
||||
wallpaperId,
|
||||
ScreenType.HOME,
|
||||
settings.shuffleEnabled
|
||||
)
|
||||
applySpecificSingle(
|
||||
albumId,
|
||||
wallpaperId,
|
||||
ScreenType.LOCK,
|
||||
settings.shuffleEnabled
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
ScreenType.LIVE -> error(getString(R.string.static_mode_required))
|
||||
}
|
||||
Log.d(TAG, "Selected wallpaper applied to $screenType")
|
||||
}
|
||||
|
||||
private suspend fun applySpecificSingle(
|
||||
albumId: String,
|
||||
wallpaperId: String,
|
||||
screenType: ScreenType,
|
||||
shuffle: Boolean
|
||||
) {
|
||||
val bitmap = renderSpecific(albumId, wallpaperId, screenType)
|
||||
try {
|
||||
val which = if (screenType == ScreenType.HOME) {
|
||||
WallpaperManager.FLAG_SYSTEM
|
||||
} else {
|
||||
WallpaperManager.FLAG_LOCK
|
||||
}
|
||||
wallpaperManager.setBitmapChecked(bitmap, which)
|
||||
changeWallpaperUseCase.completeSpecific(albumId, screenType, wallpaperId, shuffle)
|
||||
} finally {
|
||||
bitmap.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun renderSpecific(
|
||||
albumId: String,
|
||||
wallpaperId: String,
|
||||
screenType: ScreenType
|
||||
): Bitmap = when (val result = reapplyEffectsUseCase(albumId, screenType, wallpaperId)) {
|
||||
is PaperizeResult.Success -> result.data
|
||||
is PaperizeResult.Error -> throw asException(result.exception)
|
||||
PaperizeResult.Loading -> error("Unexpected loading result")
|
||||
}
|
||||
|
||||
private fun handleReapplyEffects(screenType: ScreenType, startId: Int) {
|
||||
serviceScope.launch {
|
||||
wallpaperChangeLock.mutex.withLock {
|
||||
@@ -384,7 +537,7 @@ class WallpaperChangeService : Service() {
|
||||
return NotificationCompat.Builder(this, Constants.NOTIFICATION_CHANNEL_ID)
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(getString(R.string.changing_wallpaper))
|
||||
.setSmallIcon(R.drawable.ic_launcher_monochrome)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setOngoing(true)
|
||||
.build()
|
||||
@@ -400,7 +553,7 @@ class WallpaperChangeService : Service() {
|
||||
val notification = NotificationCompat.Builder(this, Constants.NOTIFICATION_CHANNEL_ID)
|
||||
.setContentTitle(title)
|
||||
.setContentText(message)
|
||||
.setSmallIcon(R.drawable.ic_launcher_monochrome)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setAutoCancel(true)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
@@ -423,8 +576,10 @@ class WallpaperChangeService : Service() {
|
||||
const val ACTION_CHANGE_WALLPAPER = Constants.ACTION_CHANGE_WALLPAPER
|
||||
const val ACTION_CHANGE_WALLPAPER_AUTO =
|
||||
"com.anthonyla.paperize.ACTION_CHANGE_WALLPAPER_AUTO"
|
||||
const val ACTION_APPLY_SPECIFIC_WALLPAPER = Constants.ACTION_APPLY_SPECIFIC_WALLPAPER
|
||||
const val ACTION_REAPPLY_EFFECTS = Constants.ACTION_REAPPLY_EFFECTS
|
||||
const val EXTRA_SCREEN_TYPE = Constants.EXTRA_SCREEN_TYPE
|
||||
const val EXTRA_WALLPAPER_ID = Constants.EXTRA_WALLPAPER_ID
|
||||
private const val ERROR_NOTIFICATION_ID = Constants.NOTIFICATION_ID + 1
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,9 @@ import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import kotlinx.coroutines.flow.first
|
||||
import com.anthonyla.paperize.core.ScreenType
|
||||
import com.anthonyla.paperize.core.WallpaperMode
|
||||
import com.anthonyla.paperize.core.constants.Constants
|
||||
import com.anthonyla.paperize.domain.model.ScheduleSettings
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
@@ -52,7 +54,8 @@ class WallpaperScheduler @Inject constructor(
|
||||
screenType: ScreenType,
|
||||
intervalMinutes: Int,
|
||||
networkRequired: Boolean = false,
|
||||
requireCharging: Boolean = false
|
||||
requireCharging: Boolean = false,
|
||||
resetInterval: Boolean = false
|
||||
) {
|
||||
|
||||
val adjustedInterval = intervalMinutes.toLong().coerceAtLeast(Constants.MIN_INTERVAL_MINUTES.toLong())
|
||||
@@ -79,10 +82,19 @@ class WallpaperScheduler @Inject constructor(
|
||||
.setConstraints(constraints)
|
||||
.setInputData(inputData)
|
||||
.addTag(getWorkTag(screenType))
|
||||
.apply {
|
||||
// New periodic work otherwise runs immediately. Unlike an initial delay, this
|
||||
// one-run deadline also survives unrelated UPDATE requests from settings edits.
|
||||
if (resetInterval) {
|
||||
setNextScheduleTimeOverride(
|
||||
System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(adjustedInterval)
|
||||
)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
|
||||
// Enqueue work with UPDATE policy to update existing work without triggering immediate run
|
||||
// Only runs immediately on first setup when no existing work exists
|
||||
// Preserve the existing work and explicitly move only the next run after a manual change.
|
||||
// Replacing periodic work starts a new first period, which can otherwise run immediately.
|
||||
workManager.enqueueUniquePeriodicWork(
|
||||
workName,
|
||||
ExistingPeriodicWorkPolicy.UPDATE,
|
||||
@@ -92,6 +104,26 @@ class WallpaperScheduler @Inject constructor(
|
||||
Log.d(TAG, "Scheduled $screenType wallpaper change every $adjustedInterval minutes")
|
||||
}
|
||||
|
||||
/** Reset only the automatic schedules affected by a successful manual change. */
|
||||
fun resetAfterManualChange(
|
||||
screenType: ScreenType,
|
||||
settings: ScheduleSettings,
|
||||
wallpaperMode: WallpaperMode
|
||||
) {
|
||||
scheduledScreensToReset(screenType, settings, wallpaperMode).forEach { scheduledScreen ->
|
||||
val interval = when (scheduledScreen) {
|
||||
ScreenType.HOME, ScreenType.BOTH -> settings.homeIntervalMinutes
|
||||
ScreenType.LOCK -> settings.lockIntervalMinutes
|
||||
ScreenType.LIVE -> settings.liveIntervalMinutes
|
||||
}
|
||||
scheduleWallpaperChange(
|
||||
screenType = scheduledScreen,
|
||||
intervalMinutes = interval,
|
||||
resetInterval = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule both home and lock wallpaper changes
|
||||
*
|
||||
@@ -326,3 +358,43 @@ class WallpaperScheduler @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Pure scheduling policy shared with tests. */
|
||||
internal fun scheduledScreensToReset(
|
||||
manualScreen: ScreenType,
|
||||
settings: ScheduleSettings,
|
||||
wallpaperMode: WallpaperMode
|
||||
): Set<ScreenType> {
|
||||
if (!settings.enableChanger) return emptySet()
|
||||
|
||||
if (wallpaperMode == WallpaperMode.LIVE) {
|
||||
return if (
|
||||
manualScreen == ScreenType.LIVE &&
|
||||
settings.liveAlbumId != null &&
|
||||
settings.liveIntervalMinutes >= Constants.MIN_INTERVAL_MINUTES
|
||||
) {
|
||||
setOf(ScreenType.LIVE)
|
||||
} else {
|
||||
emptySet()
|
||||
}
|
||||
}
|
||||
|
||||
if (manualScreen == ScreenType.LIVE) return emptySet()
|
||||
|
||||
val homeActive = settings.homeEnabled && settings.homeAlbumId != null
|
||||
val lockActive = settings.lockEnabled && settings.lockAlbumId != null
|
||||
val synchronized = homeActive && lockActive &&
|
||||
settings.homeAlbumId == settings.lockAlbumId &&
|
||||
!settings.separateSchedules
|
||||
|
||||
if (synchronized) return setOf(ScreenType.BOTH)
|
||||
|
||||
return buildSet {
|
||||
if ((manualScreen == ScreenType.HOME || manualScreen == ScreenType.BOTH) && homeActive) {
|
||||
add(ScreenType.HOME)
|
||||
}
|
||||
if ((manualScreen == ScreenType.LOCK || manualScreen == ScreenType.BOTH) && lockActive) {
|
||||
add(ScreenType.LOCK)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M7,2h11c1.1,0 2,0.9 2,2v14h-2V4H7V2z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M4,5h11c1.1,0 2,0.9 2,2v13c0,1.1 -0.9,2 -2,2H4c-1.1,0 -2,-0.9 -2,-2V7c0,-1.1 0.9,-2 2,-2zM5,8a1.5,1.5 0,1 0,0 3a1.5,1.5 0,0 0,0 -3zM4,19h11l-3.5,-5l-2.5,3l-1.5,-2L4,19z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,219 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Paperize</string>
|
||||
<string name="import_adding_folder">正在添加文件夹…</string>
|
||||
<string name="import_adding_wallpapers">正在添加壁纸…</string>
|
||||
<string name="import_scanning">正在扫描… 已找到 %1$d 张</string>
|
||||
<string name="import_saving">正在保存 %1$d / %2$d</string>
|
||||
<string name="home">主页</string>
|
||||
<string name="settings_screen">设置</string>
|
||||
<string name="wallpaper">壁纸</string>
|
||||
<string name="library">图库</string>
|
||||
<string name="back">返回</string>
|
||||
<string name="add_folder">添加文件夹</string>
|
||||
<string name="add_album">添加相册</string>
|
||||
<string name="enter_the_name_of_the_album">输入相册名称</string>
|
||||
<string name="album_name">相册名称</string>
|
||||
<string name="cancel">取消</string>
|
||||
<string name="save">保存</string>
|
||||
<string name="delete_album">删除</string>
|
||||
<string name="change_name">重命名</string>
|
||||
<string name="no_album_selected">未选择相册</string>
|
||||
<string name="currently_selected_album">当前选中的相册</string>
|
||||
<string name="agree">同意</string>
|
||||
<string name="welcome">欢迎</string>
|
||||
<string name="continue_button">开始使用</string>
|
||||
<string name="allow">允许</string>
|
||||
<string name="privacy_policy">隐私政策</string>
|
||||
<string name="reset_to_default">恢复默认</string>
|
||||
<string name="reset_all_data">重置所有数据</string>
|
||||
<string name="are_you_sure_you_want_to_reset_all_settings_and_data_to_default">确定要将所有设置和数据恢复默认吗?</string>
|
||||
<string name="confirm">确定</string>
|
||||
<string name="selected_count">已选择 %1$s</string>
|
||||
<string name="please_read_and_agree_to_the_following_privacy_notice_to_use_the_app">请阅读并同意以下隐私声明后使用本应用。</string>
|
||||
<string name="privacy_notice">隐私声明</string>
|
||||
<string name="are_you_sure_you_want_to_delete_this">确定要删除吗?</string>
|
||||
<string name="delete_album_question">删除相册?</string>
|
||||
<string name="animation">动画</string>
|
||||
<string name="increase_visual_appeal">提升视觉观感</string>
|
||||
<string name="dark_mode">深色模式</string>
|
||||
<string name="easier_on_the_eyes">更护眼</string>
|
||||
<string name="material_you">Material You</string>
|
||||
<string name="dynamic_theming">动态取色</string>
|
||||
<string name="click_here_to_view_our_privacy_policy">点击此处查看我们的隐私政策</string>
|
||||
<string name="appearance">外观</string>
|
||||
<string name="about">关于</string>
|
||||
<plurals name="wallpaper_count" comment="wallpaper_count [one] [other]">
|
||||
<item quantity="other">%d 张壁纸</item>
|
||||
</plurals>
|
||||
<string name="privacy_intro_title">简介</string>
|
||||
<string name="privacy_intro_content">欢迎使用 %1$s!本隐私声明说明我们在你使用本应用时如何收集、使用和保护你的个人信息。使用 %1$s 即表示你同意本声明所述的条款。</string>
|
||||
<string name="privacy_data_collection_title">数据收集</string>
|
||||
<string name="privacy_data_collection_content">通知:%1$s 会请求发送通知的权限,用于显示壁纸更换、后台操作和错误通知。它不会读取其他应用的通知,也不会根据这些通知推荐壁纸。\n\n本地文件:%1$s 会访问你选择的图片和文件夹,以便将图片设为壁纸。我们不会把这些文件上传或传输到任何外部服务器。</string>
|
||||
<string name="privacy_information_usage_title">信息使用</string>
|
||||
<string name="privacy_information_usage_content">个人数据:我们不收集或存储任何个人数据,例如姓名、电子邮箱地址或电话号码。\n\n使用情况分析:%1$s 不会跟踪你的使用行为,也不会收集分析数据。</string>
|
||||
<string name="privacy_data_security_title">数据安全</string>
|
||||
<string name="privacy_data_security_content">设备本地存储:%1$s 使用的所有数据都保留在你的设备上。我们不会向外部传输或存储任何数据。</string>
|
||||
<string name="no_albums_found">未找到相册</string>
|
||||
<string name="empty_album">空相册</string>
|
||||
<string name="empty_album_message">这个相册里还没有壁纸。请先向相册中添加壁纸,然后再选择它。</string>
|
||||
<string name="ok">确定</string>
|
||||
<string name="fill">填充</string>
|
||||
<string name="fit">适应</string>
|
||||
<string name="stretch">拉伸</string>
|
||||
<string name="change_brightness">亮度效果</string>
|
||||
<string name="home_screen_btn">主屏幕</string>
|
||||
<string name="lock_screen_btn">锁屏</string>
|
||||
<string name="individual_scheduling">分别定时</string>
|
||||
<string name="show_interval_sliders">显示间隔滑块</string>
|
||||
<string name="interval_text">时间间隔</string>
|
||||
<string name="change_blur">模糊效果</string>
|
||||
<string name="lock">锁屏</string>
|
||||
<string name="change_vignette">暗角效果</string>
|
||||
<string name="none">无</string>
|
||||
<string name="gray_filter">灰度滤镜</string>
|
||||
<string name="folders">文件夹</string>
|
||||
<string name="wallpapers_sort">壁纸</string>
|
||||
<string name="close">关闭</string>
|
||||
<string name="shuffle">随机</string>
|
||||
<string name="days_txt">天</string>
|
||||
<string name="hours_txt">小时</string>
|
||||
<string name="change_the_image_brightness">调整画面亮度</string>
|
||||
<string name="add_blur_to_the_image">为画面添加模糊</string>
|
||||
<string name="darken_the_edges_of_the_image">压暗画面边缘</string>
|
||||
<string name="make_the_colors_grayscale">将画面变为灰度</string>
|
||||
<string name="double_tap_to_change">双击切换</string>
|
||||
<string name="double_tap_wallpaper_to_change_it">双击壁纸即可切换</string>
|
||||
<string name="change_on_screen_off">息屏时切换</string>
|
||||
<string name="change_wallpaper_when_screen_turns_off">息屏时更换壁纸</string>
|
||||
<string name="parallax_effect">视差效果</string>
|
||||
<string name="wallpaper_moves_with_screen_scroll">在桌面页面之间滑动可移动壁纸(需要桌面支持)</string>
|
||||
<string name="live_wallpaper_name">Paperize 动态壁纸</string>
|
||||
<string name="live_wallpaper_description">带特效与交互功能的动态壁纸</string>
|
||||
<string name="adaptive_brightness">自适应亮度</string>
|
||||
<string name="adjust_brightness_based_on_mode">根据深色/浅色模式调整亮度</string>
|
||||
<string name="randomly_shuffle_the_wallpapers">随机打乱壁纸顺序</string>
|
||||
<string name="changing_wallpaper">正在更换壁纸…</string>
|
||||
<string name="add_wallpapers">添加壁纸</string>
|
||||
<string name="select_album">选择相册</string>
|
||||
<string name="sort">排序</string>
|
||||
<string name="notification_permission_title">开启通知</string>
|
||||
<string name="notification_permission_description">允许 Paperize 发送壁纸更换通知,以及在后台运行时显示通知。你可以随时在设置中更改。</string>
|
||||
<string name="skip">跳过</string>
|
||||
<string name="permission_granted">已授予权限</string>
|
||||
|
||||
<!-- Content Descriptions for Accessibility -->
|
||||
<string name="content_desc_clear_selection">清除选择</string>
|
||||
<string name="content_desc_select_all">全选</string>
|
||||
<string name="content_desc_delete_selected">删除所选</string>
|
||||
<string name="content_desc_expand">展开</string>
|
||||
<string name="content_desc_collapse">收起</string>
|
||||
<string name="content_desc_sort_items">排序项目</string>
|
||||
<string name="content_desc_save">保存</string>
|
||||
<string name="content_desc_current_lock_wallpaper">当前锁屏壁纸</string>
|
||||
<string name="content_desc_current_home_wallpaper">当前主屏幕壁纸</string>
|
||||
<string name="content_desc_selected">已选择</string>
|
||||
<string name="content_desc_not_selected">未选择</string>
|
||||
|
||||
<!-- UI Labels and Status -->
|
||||
<string name="enabled">已启用</string>
|
||||
<string name="wallpaper_changer">壁纸更换</string>
|
||||
<string name="wallpaper_changer_description">暂停或恢复定时切换,不会清除你的相册。</string>
|
||||
<string name="horizontal_wallpaper_scrolling">横向滚动</string>
|
||||
<string name="horizontal_wallpaper_scrolling_description">允许宽幅「填充」壁纸在桌面页面之间移动。锁屏壁纸保持居中。</string>
|
||||
<string name="disabled">已禁用</string>
|
||||
<string name="lock_album_label">锁屏相册</string>
|
||||
<string name="home_album_label">主屏幕相册</string>
|
||||
<string name="scaling">缩放</string>
|
||||
<string name="wallpaper_effects_title">壁纸效果</string>
|
||||
<string name="visual_effects">视觉效果</string>
|
||||
<string name="interactive_effects">交互效果</string>
|
||||
<string name="current_wallpapers">当前壁纸</string>
|
||||
|
||||
<!-- Tab Titles -->
|
||||
|
||||
<!-- Sort Options -->
|
||||
<string name="sort_name_asc">名称(A-Z)</string>
|
||||
<string name="sort_name_desc">名称(Z-A)</string>
|
||||
<string name="sort_date_added_asc">添加日期(最早优先)</string>
|
||||
<string name="sort_date_added_desc">添加日期(最新优先)</string>
|
||||
<string name="sort_date_modified_asc">修改日期(最早优先)</string>
|
||||
<string name="sort_date_modified_desc">修改日期(最新优先)</string>
|
||||
<string name="sort_a_z">按 A-Z 排序</string>
|
||||
<string name="sort_z_a">按 Z-A 排序</string>
|
||||
<string name="sort_by_newest">按最新排序</string>
|
||||
<string name="sort_by_oldest">按最早排序</string>
|
||||
|
||||
<!-- Time Interval Picker -->
|
||||
<string name="mins">分钟</string>
|
||||
<string name="total_interval">总计: </string>
|
||||
<string name="time_unit_min">分</string>
|
||||
<string name="live_short_interval_note">低于 15 分钟的间隔仅在 Paperize 作为可见的动态壁纸运行时生效。</string>
|
||||
|
||||
<!-- Notification Service -->
|
||||
<string name="notification_channel_description">壁纸更换通知</string>
|
||||
<string name="no_wallpapers_in_album">相册中没有壁纸</string>
|
||||
<string name="wallpaper_changer_disabled_empty_album">相册为空,壁纸更换已停用。</string>
|
||||
|
||||
<!-- Error Messages -->
|
||||
<string name="error_failed_to_build_queue">无法构建壁纸队列</string>
|
||||
<string name="error_no_valid_wallpaper_after_retries">多次重试后仍未找到有效壁纸</string>
|
||||
<string name="wallpaper_not_found">这张壁纸已不可用。</string>
|
||||
<string name="static_mode_required">应用单张壁纸前,请先切换到静态壁纸模式。</string>
|
||||
|
||||
<!-- OEM Compatibility Warnings -->
|
||||
<string name="parallax_may_not_work">视差效果在你的系统或桌面上可能无法生效。</string>
|
||||
|
||||
<!-- Plurals -->
|
||||
<plurals name="time_unit_hours">
|
||||
<item quantity="other">小时</item>
|
||||
</plurals>
|
||||
<plurals name="time_unit_days">
|
||||
<item quantity="other">天</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Material 3 Expressive UI Strings -->
|
||||
<string name="create_first_album_hint">点击 + 创建你的第一个相册</string>
|
||||
|
||||
<!-- Album Labels -->
|
||||
<string name="album_suffix"> 相册</string>
|
||||
<!-- Wallpaper Mode Selection -->
|
||||
<string name="choose_wallpaper_mode">选择壁纸模式</string>
|
||||
<string name="change_later_in_settings">之后可以在设置中更改</string>
|
||||
<string name="static_mode">静态模式</string>
|
||||
<string name="static_mode_description">使用系统壁纸管理器进行经典的壁纸切换。简单省电,仅支持静态图片。</string>
|
||||
<string name="live_wallpaper_mode">动态壁纸模式</string>
|
||||
<string name="live_wallpaper_mode_description">带硬件加速特效与交互功能(双击、视差)的高级动态壁纸。</string>
|
||||
|
||||
<!-- Live Wallpaper Selection Dialog -->
|
||||
<string name="select_live_wallpaper">选择动态壁纸</string>
|
||||
<string name="select_live_wallpaper_instruction">若想以动态壁纸模式使用 Paperize,你需要在系统设置中把它选为动态壁纸。</string>
|
||||
<string name="open_wallpaper_picker">打开壁纸选择器</string>
|
||||
<string name="later">稍后</string>
|
||||
|
||||
<!-- Settings Mode Switcher -->
|
||||
<string name="wallpaper_mode_setting">壁纸模式</string>
|
||||
<string name="current_mode">当前模式</string>
|
||||
<string name="mode_static">静态</string>
|
||||
<string name="mode_live_wallpaper">动态壁纸</string>
|
||||
<string name="switch_button">切换</string>
|
||||
<string name="mode_switch_warning">切换模式将重置所有相册、壁纸和设置,此操作无法撤销。</string>
|
||||
<string name="switch_mode_dialog_title">切换到%1$s模式?</string>
|
||||
<string name="switch_mode_dialog_description">这将重置所有相册、壁纸和定时设置,此操作无法撤销。\n\n你需要重新添加相册并配置壁纸设置。</string>
|
||||
<string name="switch_mode_button">切换模式</string>
|
||||
<string name="open_wallpaper_picker_instruction_newline">\n点击下方的「打开壁纸选择器」,在可用动态壁纸列表中选择 Paperize。</string>
|
||||
<string name="loading_placeholder">…</string>
|
||||
<string name="album_name_exists_error">已存在同名相册</string>
|
||||
<string name="battery_optimization">电池优化</string>
|
||||
<string name="battery_optimization_description">关闭电池优化,以确保后台壁纸切换稳定可靠。</string>
|
||||
<string name="check_status">检查状态</string>
|
||||
<string name="ignoring">已忽略(推荐)</string>
|
||||
<string name="optimizing">优化中(可能延迟切换)</string>
|
||||
<string name="reliability">可靠性</string>
|
||||
<string name="change_wallpaper_now">立即更换壁纸</string>
|
||||
<string name="set_wallpaper">设为壁纸</string>
|
||||
<string name="home_and_lock_screens">主屏幕和锁屏</string>
|
||||
<string name="individual_wallpaper_static_only">请切换到静态模式以设置单张壁纸。</string>
|
||||
<string name="change_next_wallpaper_shortcut">切换到下一张已配置的壁纸</string>
|
||||
|
||||
</resources>
|
||||
@@ -50,7 +50,7 @@
|
||||
<string name="privacy_intro_title">Introduction</string>
|
||||
<string name="privacy_intro_content">Welcome to %1$s! This privacy notice outlines how we collect, use, and protect your personal information when you use our mobile application. By using %1$s, you agree to the terms described in this notice.</string>
|
||||
<string name="privacy_data_collection_title">Data Collection</string>
|
||||
<string name="privacy_data_collection_content">Notification Access: %1$s requests notification access to provide you with personalized wallpaper recommendations based on your notifications. We do not store any notification content or personally identifiable information (PII) outside of your device.\n\nLocal Files: %1$s accesses files stored on your device to allow you to set them as wallpapers. We do not upload or transfer these files to any external servers.</string>
|
||||
<string name="privacy_data_collection_content">Notifications: %1$s requests permission to display its own wallpaper-change, background-operation, and error notifications. It does not read notifications from other apps or use them to recommend wallpapers.\n\nLocal Files: %1$s accesses the images and folders you select so it can set them as wallpapers. We do not upload or transfer these files to any external servers.</string>
|
||||
<string name="privacy_information_usage_title">Information Usage</string>
|
||||
<string name="privacy_information_usage_content">Personal Data: We do not collect or store any personal data such as names, email addresses, or phone numbers.\n\nUsage Analytics: %1$s does not track your usage behavior or collect analytics data.</string>
|
||||
<string name="privacy_data_security_title">Data Security</string>
|
||||
@@ -149,6 +149,7 @@
|
||||
<string name="mins">Mins</string>
|
||||
<string name="total_interval">Total: </string>
|
||||
<string name="time_unit_min">min</string>
|
||||
<string name="live_short_interval_note">Intervals under 15 minutes run only while Paperize is the visible live wallpaper.</string>
|
||||
|
||||
<!-- Notification Service -->
|
||||
<string name="notification_channel_description">Wallpaper change notifications</string>
|
||||
@@ -158,6 +159,8 @@
|
||||
<!-- Error Messages -->
|
||||
<string name="error_failed_to_build_queue">Failed to build wallpaper queue</string>
|
||||
<string name="error_no_valid_wallpaper_after_retries">Could not find a valid wallpaper after retries</string>
|
||||
<string name="wallpaper_not_found">This wallpaper is no longer available.</string>
|
||||
<string name="static_mode_required">Switch to static wallpaper mode before applying an individual wallpaper.</string>
|
||||
|
||||
<!-- OEM Compatibility Warnings -->
|
||||
<string name="parallax_may_not_work">Parallax effect may not work with your OEM or launcher.</string>
|
||||
@@ -211,6 +214,9 @@
|
||||
<string name="optimizing">Optimizing (May delay changes)</string>
|
||||
<string name="reliability">Reliability</string>
|
||||
<string name="change_wallpaper_now">Change wallpaper now</string>
|
||||
<string name="set_wallpaper">Set wallpaper</string>
|
||||
<string name="home_and_lock_screens">Home and lock screens</string>
|
||||
<string name="individual_wallpaper_static_only">Switch to static mode to set an individual wallpaper.</string>
|
||||
<string name="change_next_wallpaper_shortcut">Change to the next configured wallpaper</string>
|
||||
|
||||
</resources>
|
||||
@@ -26,7 +26,7 @@ class ScheduleSettingsTest {
|
||||
|
||||
assertEquals(Constants.MIN_INTERVAL_MINUTES, validated.homeIntervalMinutes)
|
||||
assertEquals(Constants.MIN_INTERVAL_MINUTES, validated.lockIntervalMinutes)
|
||||
assertEquals(Constants.MIN_INTERVAL_MINUTES, validated.liveIntervalMinutes)
|
||||
assertEquals(Constants.MIN_LIVE_INTERVAL_MINUTES, validated.liveIntervalMinutes)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -44,6 +44,15 @@ class ScheduleSettingsTest {
|
||||
assertEquals(30, validated.liveIntervalMinutes)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `visible live timer is used only below WorkManager minimum`() {
|
||||
assertFalse(usesVisibleLiveTimer(0))
|
||||
assertTrue(usesVisibleLiveTimer(1))
|
||||
assertTrue(usesVisibleLiveTimer(14))
|
||||
assertFalse(usesVisibleLiveTimer(15))
|
||||
assertFalse(usesVisibleLiveTimer(60))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `validate validates effect percentages`() {
|
||||
val effects = WallpaperEffects(
|
||||
|
||||
@@ -69,6 +69,25 @@ class ChangeWallpaperUseCaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `complete specific records selected item and respects shuffle`() = runTest {
|
||||
coEvery {
|
||||
repository.getNextWallpaperInQueue("album", ScreenType.HOME)
|
||||
} returns null
|
||||
coEvery {
|
||||
repository.buildWallpaperQueue("album", ScreenType.HOME, true)
|
||||
} returns Result.Success(Unit)
|
||||
|
||||
useCase.completeSpecific("album", ScreenType.HOME, "selected", shuffle = true)
|
||||
|
||||
coVerifyOrder {
|
||||
repository.setCurrentWallpaper("album", ScreenType.HOME, "selected")
|
||||
repository.getNextWallpaperInQueue("album", ScreenType.HOME)
|
||||
repository.buildWallpaperQueue("album", ScreenType.HOME, true)
|
||||
repository.removeWallpaperFromQueue("album", ScreenType.HOME, "selected")
|
||||
}
|
||||
}
|
||||
|
||||
private fun preparedWallpaper() = PreparedWallpaper(
|
||||
bitmap = mockk<Bitmap>(relaxed = true),
|
||||
albumId = "album",
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
@file:Suppress("RestrictedApi")
|
||||
|
||||
package com.anthonyla.paperize.service.worker
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.Operation
|
||||
import androidx.work.PeriodicWorkRequest
|
||||
import androidx.work.WorkManager
|
||||
import com.anthonyla.paperize.core.ScreenType
|
||||
import com.anthonyla.paperize.core.WallpaperMode
|
||||
import com.anthonyla.paperize.core.constants.Constants
|
||||
import com.anthonyla.paperize.domain.model.ScheduleSettings
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.mockkObject
|
||||
import io.mockk.mockkStatic
|
||||
import io.mockk.unmockkAll
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class WallpaperSchedulerTest {
|
||||
private val context = mockk<Context>()
|
||||
private val workManager = mockk<WorkManager>()
|
||||
private val operation = mockk<Operation>()
|
||||
private val enqueued = mutableListOf<Triple<String, ExistingPeriodicWorkPolicy, PeriodicWorkRequest>>()
|
||||
private lateinit var scheduler: WallpaperScheduler
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockkObject(WorkManager.Companion)
|
||||
mockkStatic(Log::class)
|
||||
every { WorkManager.getInstance(context) } returns workManager
|
||||
every { Log.d(any(), any()) } returns 0
|
||||
every { workManager.enqueueUniquePeriodicWork(any(), any(), any()) } answers {
|
||||
enqueued += Triple(firstArg(), secondArg(), thirdArg())
|
||||
operation
|
||||
}
|
||||
scheduler = WallpaperScheduler(context)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() = unmockkAll()
|
||||
|
||||
@Test
|
||||
fun `manual resets defer the next run for a full interval for every target`() {
|
||||
val intervalMillis = TimeUnit.MINUTES.toMillis(60)
|
||||
ScreenType.entries.forEach { screen ->
|
||||
val enqueueTime = System.currentTimeMillis()
|
||||
scheduler.scheduleWallpaperChange(screen, 60, resetInterval = true)
|
||||
|
||||
val (_, policy, request) = enqueued.last()
|
||||
assertEquals(ExistingPeriodicWorkPolicy.UPDATE, policy)
|
||||
assertEquals(screen.name, request.workSpec.input.getString(Constants.EXTRA_SCREEN_TYPE))
|
||||
request.workSpec.lastEnqueueTime = enqueueTime
|
||||
val nextRun = request.workSpec.calculateNextRunTime()
|
||||
assertTrue(nextRun >= enqueueTime + intervalMillis)
|
||||
assertTrue(nextRun <= System.currentTimeMillis() + intervalMillis)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ordinary scheduling retains update policy and immediate first activation`() {
|
||||
scheduler.scheduleWallpaperChange(ScreenType.HOME, 60)
|
||||
|
||||
val (_, policy, request) = enqueued.single()
|
||||
assertEquals(ExistingPeriodicWorkPolicy.UPDATE, policy)
|
||||
assertEquals(0L, request.workSpec.initialDelay)
|
||||
assertEquals(Long.MAX_VALUE, request.workSpec.nextScheduleTimeOverride)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `manual reset delay uses the same minimum as the periodic interval`() {
|
||||
val before = System.currentTimeMillis()
|
||||
scheduler.scheduleWallpaperChange(ScreenType.HOME, 1, resetInterval = true)
|
||||
|
||||
val request = enqueued.single().third
|
||||
val minimumMillis = TimeUnit.MINUTES.toMillis(15)
|
||||
assertEquals(minimumMillis, request.workSpec.intervalDuration)
|
||||
assertTrue(request.workSpec.calculateNextRunTime() >= before + minimumMillis)
|
||||
assertTrue(request.workSpec.calculateNextRunTime() <= System.currentTimeMillis() + minimumMillis)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `manual home reset delays only its active independent schedule`() {
|
||||
val before = System.currentTimeMillis()
|
||||
scheduler.resetAfterManualChange(
|
||||
ScreenType.HOME,
|
||||
ScheduleSettings(
|
||||
enableChanger = true,
|
||||
separateSchedules = true,
|
||||
homeEnabled = true,
|
||||
lockEnabled = true,
|
||||
homeAlbumId = "home",
|
||||
lockAlbumId = "lock",
|
||||
homeIntervalMinutes = 60,
|
||||
lockIntervalMinutes = 90
|
||||
),
|
||||
WallpaperMode.STATIC
|
||||
)
|
||||
|
||||
val (name, policy, request) = enqueued.single()
|
||||
assertEquals(Constants.WORK_NAME_HOME, name)
|
||||
assertEquals(ExistingPeriodicWorkPolicy.UPDATE, policy)
|
||||
assertTrue(request.workSpec.calculateNextRunTime() >= before + TimeUnit.MINUTES.toMillis(60))
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package com.anthonyla.paperize.service.worker
|
||||
|
||||
import com.anthonyla.paperize.core.ScreenType
|
||||
import com.anthonyla.paperize.core.WallpaperMode
|
||||
import com.anthonyla.paperize.domain.model.ScheduleSettings
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class WallpaperSchedulingPolicyTest {
|
||||
@Test
|
||||
fun `manual synchronized change resets the shared job`() {
|
||||
val settings = ScheduleSettings(
|
||||
enableChanger = true,
|
||||
homeEnabled = true,
|
||||
lockEnabled = true,
|
||||
homeAlbumId = "album",
|
||||
lockAlbumId = "album"
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
setOf(ScreenType.BOTH),
|
||||
scheduledScreensToReset(ScreenType.HOME, settings, WallpaperMode.STATIC)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `manual both change resets each independent job`() {
|
||||
val settings = ScheduleSettings(
|
||||
enableChanger = true,
|
||||
separateSchedules = true,
|
||||
homeEnabled = true,
|
||||
lockEnabled = true,
|
||||
homeAlbumId = "home",
|
||||
lockAlbumId = "lock"
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
setOf(ScreenType.HOME, ScreenType.LOCK),
|
||||
scheduledScreensToReset(ScreenType.BOTH, settings, WallpaperMode.STATIC)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `manual change does not create a disabled schedule`() {
|
||||
assertEquals(
|
||||
emptySet<ScreenType>(),
|
||||
scheduledScreensToReset(
|
||||
ScreenType.BOTH,
|
||||
ScheduleSettings(enableChanger = false),
|
||||
WallpaperMode.STATIC
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `short live interval belongs to visible engine instead of WorkManager`() {
|
||||
val settings = ScheduleSettings(
|
||||
enableChanger = true,
|
||||
liveAlbumId = "live",
|
||||
liveIntervalMinutes = 14
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
emptySet<ScreenType>(),
|
||||
scheduledScreensToReset(ScreenType.LIVE, settings, WallpaperMode.LIVE)
|
||||
)
|
||||
assertEquals(
|
||||
setOf(ScreenType.LIVE),
|
||||
scheduledScreensToReset(
|
||||
ScreenType.LIVE,
|
||||
settings.copy(liveIntervalMinutes = 15),
|
||||
WallpaperMode.LIVE
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
+14
-14
@@ -1,17 +1,17 @@
|
||||
[versions]
|
||||
androidGradlePlugin = "9.1.0"
|
||||
kotlin = "2.3.20"
|
||||
androidGradlePlugin = "9.3.2"
|
||||
kotlin = "2.4.10"
|
||||
hilt = "2.60.1"
|
||||
ksp = "2.3.6"
|
||||
material = "1.13.0"
|
||||
coil = "3.4.0"
|
||||
ksp = "2.3.11"
|
||||
material = "1.14.0"
|
||||
coil = "3.6.0"
|
||||
|
||||
[libraries]
|
||||
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version = "0.37.3" }
|
||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.13.0" }
|
||||
androidx-animation = { module = "androidx.compose.animation:animation" }
|
||||
androidx-compose-bom = { module = "androidx.compose:compose-bom", version = "2026.06.01" }
|
||||
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.18.0" }
|
||||
androidx-compose-bom = { module = "androidx.compose:compose-bom", version = "2026.08.00" }
|
||||
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.19.0" }
|
||||
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version = "1.2.0" }
|
||||
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version = "1.2.1" }
|
||||
androidx-datastore = { module = "androidx.datastore:datastore", version = "1.2.1" }
|
||||
@@ -19,19 +19,19 @@ androidx-documentfile = { module = "androidx.documentfile:documentfile", version
|
||||
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version = "3.7.0" }
|
||||
androidx-exifinterface = { module = "androidx.exifinterface:exifinterface", version = "1.4.2" }
|
||||
androidx-foundation = { module = "androidx.compose.foundation:foundation" }
|
||||
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version = "1.3.0" }
|
||||
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version = "1.4.0" }
|
||||
androidx-hilt-work = { module = "androidx.hilt:hilt-work", version = "1.4.0" }
|
||||
androidx-hilt-compiler = { module = "androidx.hilt:hilt-compiler", version = "1.4.0" }
|
||||
androidx-junit = { module = "androidx.test.ext:junit", version = "1.3.0" }
|
||||
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version = "2.10.0" }
|
||||
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version = "2.10.0" }
|
||||
androidx-lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version = "2.10.0" }
|
||||
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version = "2.11.0" }
|
||||
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version = "2.11.0" }
|
||||
androidx-lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version = "2.11.0" }
|
||||
androidx-material = { module = "androidx.compose.material:material" }
|
||||
androidx-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" }
|
||||
# v4 uses Material 3 expressive APIs that are not available in the stable 1.4 line.
|
||||
# Keep this known-good alpha pinned until the expressive API reaches stable.
|
||||
androidx-material3 = { module = "androidx.compose.material3:material3", version = "1.5.0-alpha16" }
|
||||
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version = "2.9.8" }
|
||||
androidx-material3 = { module = "androidx.compose.material3:material3", version = "1.5.0-alpha27" }
|
||||
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version = "2.10.0" }
|
||||
androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version = "1.4.1" }
|
||||
androidx-room-ktx = { module = "androidx.room:room-ktx", version = "2.8.4" }
|
||||
androidx-room-compiler = { module = "androidx.room:room-compiler", version = "2.8.4" }
|
||||
@@ -56,7 +56,7 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa
|
||||
lazycolumnscrollbar = { module = "com.github.nanihadesuka:LazyColumnScrollbar", version = "2.2.0" }
|
||||
lottie-compose = { module = "com.airbnb.android:lottie-compose", version = "6.7.1" }
|
||||
toolbar-compose = { module = "me.onebone:toolbar-compose", version = "2.3.5" }
|
||||
zoomable = { module = "net.engawapg.lib:zoomable", version = "2.11.1" }
|
||||
zoomable = { module = "net.engawapg.lib:zoomable", version = "2.13.0" }
|
||||
reorderable = { group = "sh.calvin.reorderable", name = "reorderable", version = "3.1.0" }
|
||||
|
||||
[plugins]
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=9c0f7faeeb306cb14e4279a3e084ca6b596894089a0638e68a07c945a32c9e14
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
|
||||
distributionSha256Sum=acd53f1edaf02f1a8ff99879f8a34b302661a057d9b063ae9e35b552f804d20a
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
|
||||
Reference in new issue
Block a user