Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74d2c614fd | ||
|
|
da0d8c45e6 | ||
|
|
e87d8116a6 | ||
|
|
8aaff066b3 | ||
|
|
685c9d1981 | ||
|
|
81ae25035e | ||
|
|
530ff36a16 | ||
|
|
9fd52e7bc4 | ||
|
|
0c2ca68dcd | ||
|
|
e7c92eae71 | ||
|
|
7b26e323ac | ||
|
|
b0069e3bc9 | ||
|
|
8582bc903b | ||
|
|
8690284ac2 | ||
|
|
c9e485ac88 | ||
|
|
9d577880e0 | ||
|
|
09bacfb3e5 | ||
|
|
3fd9cec67d | ||
|
|
ac7a1e0cb0 | ||
|
|
53ba0a2347 | ||
|
|
83cc89e1b3 | ||
|
|
655c4a91e5 | ||
|
|
083f269605 | ||
|
|
9880bac0c6 | ||
|
|
0f87776d16 | ||
|
|
ed291459d1 | ||
|
|
bc1eb7f996 | ||
|
|
8366965a03 | ||
|
|
904f77191c | ||
|
|
ec9f56cf1e | ||
|
|
980527cdde | ||
|
|
efe794c63f | ||
|
|
65a677ea91 | ||
|
|
dabf63fc58 | ||
|
|
1da95e09b5 | ||
|
|
ad195a985e | ||
|
|
0e06584780 | ||
|
|
a6f44ecad5 | ||
|
|
d527fa9a80 | ||
|
|
ffe360ee80 | ||
|
|
8fd9c9b80e | ||
|
|
d77f2fe8df | ||
|
|
86c44825d9 | ||
|
|
b5d8bb5548 | ||
|
|
9000be1951 | ||
|
|
38ba5154f9 | ||
|
|
9f670031b1 | ||
|
|
c0dd7baeaa | ||
|
|
1c96dcfc4a | ||
|
|
2a3821e1e7 | ||
|
|
8b61b1d719 | ||
|
|
431df5c334 | ||
|
|
2b49a01eb4 | ||
|
|
3bc438a06d | ||
|
|
57d6b7dc8e | ||
|
|
5d87257516 | ||
|
|
cb9ab7d1af |
No files matched your search
@@ -30,11 +30,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
uses: actions/upload-pages-artifact@v4
|
||||
with:
|
||||
# Upload entire repository
|
||||
path: '.'
|
||||
|
||||
@@ -13,14 +13,15 @@ ksp {
|
||||
|
||||
android {
|
||||
namespace = "com.anthonyla.paperize"
|
||||
compileSdk = 35
|
||||
compileSdk = 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.anthonyla.paperize"
|
||||
minSdk = 26
|
||||
targetSdk = 37
|
||||
versionCode = 37
|
||||
versionName = "3.0.0"
|
||||
minSdk = 31
|
||||
targetSdk = 36
|
||||
versionCode = 39
|
||||
versionName = "3.1.1"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
@@ -115,7 +116,6 @@ dependencies {
|
||||
implementation(libs.androidx.glance.appwidget)
|
||||
implementation(libs.androidx.glance.material3)
|
||||
implementation(libs.androidx.glance.material)
|
||||
implementation(files("dependencies/renderscript-toolkit-release.aar"))
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" tools:node="remove"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
@@ -35,8 +38,10 @@
|
||||
android:theme="@android:style/Theme.NoDisplay">
|
||||
</activity>
|
||||
<receiver android:name=".feature.wallpaper.wallpaper_alarmmanager.WallpaperReceiver" />
|
||||
<service android:name=".feature.wallpaper.wallpaper_service.HomeWallpaperService" />
|
||||
<service android:name=".feature.wallpaper.wallpaper_service.LockWallpaperService" />
|
||||
<service android:name=".feature.wallpaper.wallpaper_service.HomeWallpaperService"
|
||||
android:foregroundServiceType="dataSync|specialUse" />
|
||||
<service android:name=".feature.wallpaper.wallpaper_service.LockWallpaperService"
|
||||
android:foregroundServiceType="dataSync|specialUse" />
|
||||
<service
|
||||
android:name=".feature.wallpaper.wallpaper_tile.ChangeWallpaperTileService"
|
||||
android:exported="true"
|
||||
@@ -90,4 +95,5 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
||||
@@ -47,4 +47,6 @@ object SettingsConstants {
|
||||
const val START_HOUR = "start_hour"
|
||||
const val START_MINUTE = "start_minute"
|
||||
const val SHUFFLE = "shuffle"
|
||||
const val SKIP_LANDSCAPE = "skip_landscape"
|
||||
const val SKIP_NON_INTERACTIVE = "skip_non_interactive"
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.ColorMatrix
|
||||
import android.graphics.ColorMatrixColorFilter
|
||||
import android.graphics.HardwareRenderer
|
||||
import android.graphics.ImageDecoder
|
||||
import android.graphics.Matrix
|
||||
import android.graphics.Paint
|
||||
@@ -32,7 +33,6 @@ import com.anthonyla.paperize.core.ScreenMetricsCompat.getScreenSize
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Metadata
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import com.google.android.renderscript.Toolkit
|
||||
import com.lazygeniouz.dfc.file.DocumentFileCompat
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -41,6 +41,13 @@ import java.io.ByteArrayOutputStream
|
||||
import java.nio.charset.Charset
|
||||
import java.util.zip.DeflaterOutputStream
|
||||
import java.util.zip.InflaterInputStream
|
||||
import android.graphics.PixelFormat
|
||||
import android.graphics.RenderEffect
|
||||
import android.graphics.RenderNode
|
||||
import android.hardware.HardwareBuffer
|
||||
import android.media.ImageReader
|
||||
import kotlin.compareTo
|
||||
import kotlin.or
|
||||
|
||||
enum class Type { HOME, LOCK, SINGLE, REFRESH }
|
||||
|
||||
@@ -313,14 +320,62 @@ fun darkenBitmap(source: Bitmap, brightnessToRetainPercent: Int): Bitmap {
|
||||
* Blur the bitmap by a certain percentage
|
||||
*/
|
||||
fun blurBitmap(source: Bitmap, percent: Int): Bitmap {
|
||||
if (percent <= 0) return source
|
||||
return try {
|
||||
val radius = (percent.coerceIn(0, 100) * 0.25f).coerceIn(1f, 25f)
|
||||
Toolkit.blur(source, radius.toInt())
|
||||
} catch (e: Exception) {
|
||||
Log.e("WallpaperUtil", "Error blurring bitmap (Renderscript): $e")
|
||||
source
|
||||
val clampedPercent = percent.coerceIn(0, 100)
|
||||
if (clampedPercent == 0) {
|
||||
return source
|
||||
}
|
||||
|
||||
val maxBlurRadius = 25.0f
|
||||
val radius = (clampedPercent / 100.0f) * maxBlurRadius
|
||||
|
||||
val imageReader = ImageReader.newInstance(
|
||||
source.width, source.height,
|
||||
PixelFormat.RGBA_8888, 1,
|
||||
HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE or HardwareBuffer.USAGE_GPU_COLOR_OUTPUT
|
||||
)
|
||||
|
||||
val renderNode = RenderNode("BlurEffect")
|
||||
val hardwareRenderer = HardwareRenderer()
|
||||
|
||||
var resultBitmap: Bitmap?
|
||||
try {
|
||||
hardwareRenderer.setSurface(imageReader.surface)
|
||||
hardwareRenderer.setContentRoot(renderNode)
|
||||
renderNode.setPosition(0, 0, source.width, source.height)
|
||||
|
||||
val blurEffect = RenderEffect.createBlurEffect(radius, radius, Shader.TileMode.MIRROR)
|
||||
renderNode.setRenderEffect(blurEffect)
|
||||
|
||||
val canvas = renderNode.beginRecording()
|
||||
canvas.drawBitmap(source, 0f, 0f, null)
|
||||
renderNode.endRecording()
|
||||
|
||||
hardwareRenderer.createRenderRequest()
|
||||
.setWaitForPresent(true)
|
||||
.syncAndDraw()
|
||||
|
||||
val image = imageReader.acquireNextImage()
|
||||
?: throw IllegalStateException("Failed to acquire blurred image")
|
||||
|
||||
val hardwareBuffer = image.hardwareBuffer
|
||||
?: throw IllegalStateException("Failed to acquire hardware buffer")
|
||||
|
||||
val hardwareBitmap = Bitmap.wrapHardwareBuffer(hardwareBuffer, null)
|
||||
?: throw IllegalStateException("Failed to create bitmap from hardware buffer")
|
||||
|
||||
// Convert hardware bitmap to regular bitmap for further processing
|
||||
resultBitmap = hardwareBitmap.copy(Bitmap.Config.ARGB_8888, false)
|
||||
|
||||
hardwareBuffer.close()
|
||||
image.close()
|
||||
|
||||
} finally {
|
||||
hardwareRenderer.destroy()
|
||||
renderNode.discardDisplayList()
|
||||
imageReader.close()
|
||||
}
|
||||
|
||||
return resultBitmap
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -649,6 +704,12 @@ fun processBitmap(
|
||||
try {
|
||||
var processedBitmap = source
|
||||
|
||||
// Apply blur first on the original size for better quality
|
||||
if (blur && blurPercent > 0) {
|
||||
processedBitmap = blurBitmap(processedBitmap, blurPercent)
|
||||
}
|
||||
|
||||
// Then scale the bitmap
|
||||
processedBitmap = when (scaling) {
|
||||
ScalingConstants.FILL -> fillBitmap(processedBitmap, width, height)
|
||||
ScalingConstants.FIT -> fitBitmap(processedBitmap, width, height)
|
||||
@@ -656,8 +717,9 @@ fun processBitmap(
|
||||
ScalingConstants.NONE -> processedBitmap
|
||||
}
|
||||
|
||||
// Ensure mutability for color effects
|
||||
if (!processedBitmap.isMutable && (darken || vignette || grayscale)) {
|
||||
Log.w("ProcessBitmap", "Bitmap became immutable before effects. Making a mutable copy.")
|
||||
Log.w("ProcessBitmap", "Bitmap became immutable. Making a mutable copy.")
|
||||
processedBitmap = processedBitmap.copy(processedBitmap.config ?: Bitmap.Config.ARGB_8888, true)
|
||||
}
|
||||
|
||||
@@ -665,15 +727,6 @@ fun processBitmap(
|
||||
processedBitmap = darkenBitmap(processedBitmap, darkenPercent)
|
||||
}
|
||||
|
||||
if (blur && blurPercent > 0) {
|
||||
val blurred = blurBitmap(processedBitmap, blurPercent)
|
||||
processedBitmap = blurred
|
||||
if (!processedBitmap.isMutable && (vignette || grayscale)) {
|
||||
Log.w("ProcessBitmap", "Bitmap became immutable after blur. Making a mutable copy.")
|
||||
processedBitmap = processedBitmap.copy(processedBitmap.config ?: Bitmap.Config.ARGB_8888, true)
|
||||
}
|
||||
}
|
||||
|
||||
if (vignette && vignettePercent > 0) {
|
||||
processedBitmap = vignetteBitmap(processedBitmap, vignettePercent)
|
||||
}
|
||||
|
||||
@@ -58,9 +58,11 @@ class SettingsDataStoreImpl(private val context: Context) : SettingsDataStore {
|
||||
|
||||
override suspend fun getInt(key: String): Int? {
|
||||
return try {
|
||||
val head = context.dataStore.data.first()
|
||||
val preferencesKey = intPreferencesKey(key)
|
||||
head[preferencesKey]?.toInt()
|
||||
val preferences = context.dataStore.data.first()
|
||||
val intKey = intPreferencesKey(key)
|
||||
val stringKey = stringPreferencesKey(key)
|
||||
|
||||
preferences[intKey] ?: preferences[stringKey]?.toIntOrNull()
|
||||
} catch (exception: Exception) {
|
||||
exception.printStackTrace()
|
||||
null
|
||||
@@ -85,14 +87,26 @@ class SettingsDataStoreImpl(private val context: Context) : SettingsDataStore {
|
||||
preferences[stringPreferencesKey(key)]
|
||||
}
|
||||
|
||||
override fun getIntFlow(key: String): Flow<Int?> = context.dataStore.data
|
||||
.catch { exception ->
|
||||
exception.printStackTrace()
|
||||
emit(emptyPreferences())
|
||||
}
|
||||
.map { preferences ->
|
||||
preferences[intPreferencesKey(key)]
|
||||
}
|
||||
override fun getIntFlow(key: String): Flow<Int?> {
|
||||
val intKey = intPreferencesKey(key)
|
||||
val stringKey = stringPreferencesKey(key)
|
||||
|
||||
return context.dataStore.data
|
||||
.catch { exception ->
|
||||
exception.printStackTrace()
|
||||
emit(emptyPreferences())
|
||||
}
|
||||
.map { preferences ->
|
||||
val valueAsInt = preferences[intKey]
|
||||
|
||||
if (valueAsInt != null) {
|
||||
valueAsInt
|
||||
} else {
|
||||
val valueAsString = preferences[stringKey]
|
||||
valueAsString?.toIntOrNull()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun deleteBoolean(key: String) {
|
||||
val preferencesKey = booleanPreferencesKey(key)
|
||||
|
||||
+10
-3
@@ -32,6 +32,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
@@ -44,10 +45,10 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.themes.PaperizeThem
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperAlarmItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperAlarmSchedulerImpl
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperReceiver
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_service.HomeWallpaperService
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import javax.inject.Inject
|
||||
import androidx.core.net.toUri
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : ComponentActivity() {
|
||||
@@ -87,6 +88,12 @@ class MainActivity : ComponentActivity() {
|
||||
requestSetWallpaperPermission.launch(Manifest.permission.SET_WALLPAPER)
|
||||
}
|
||||
|
||||
// Trigger a refresh of wallpapers when the app is opened.
|
||||
val refreshIntent = Intent(this, HomeWallpaperService::class.java).apply {
|
||||
action = HomeWallpaperService.Actions.REFRESH.toString()
|
||||
}
|
||||
startForegroundService(refreshIntent)
|
||||
|
||||
val splashScreen = installSplashScreen()
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
|
||||
@@ -109,7 +116,7 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||
val isFirstLaunch = runBlocking { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) } ?: true
|
||||
val scheduler = WallpaperAlarmSchedulerImpl(this)
|
||||
val scheduler = WallpaperAlarmSchedulerImpl(this, settingsDataStoreImpl)
|
||||
|
||||
var hasScheduleRun by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(settingsState.value) {
|
||||
@@ -239,4 +246,4 @@ class MainActivity : ComponentActivity() {
|
||||
)
|
||||
return pendingIntent != null
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
-12
@@ -131,7 +131,8 @@ fun PaperizeApp(
|
||||
homeInterval = timeInMinutes
|
||||
)
|
||||
),
|
||||
scheduler = scheduler
|
||||
scheduler = scheduler,
|
||||
context = context
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -145,7 +146,8 @@ fun PaperizeApp(
|
||||
lockInterval = timeInMinutes
|
||||
)
|
||||
),
|
||||
scheduler = scheduler
|
||||
scheduler = scheduler,
|
||||
context = context
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -190,6 +192,7 @@ fun PaperizeApp(
|
||||
),
|
||||
settingsViewModel = settingsViewModel,
|
||||
scheduler = scheduler,
|
||||
context = context,
|
||||
refreshNextTime = true
|
||||
)
|
||||
}
|
||||
@@ -232,6 +235,7 @@ fun PaperizeApp(
|
||||
),
|
||||
settingsViewModel = settingsViewModel,
|
||||
scheduler = scheduler,
|
||||
context = context,
|
||||
refreshNextTime = true,
|
||||
changeImmediate = true,
|
||||
cancelImmediate = true,
|
||||
@@ -305,7 +309,8 @@ fun PaperizeApp(
|
||||
)
|
||||
),
|
||||
settingsViewModel = settingsViewModel,
|
||||
scheduler = scheduler
|
||||
scheduler = scheduler,
|
||||
context = context
|
||||
)
|
||||
}
|
||||
else if (albumState.value.selectedAlbum.isNotEmpty() && settingsState.value.wallpaperSettings.enableChanger) {
|
||||
@@ -317,7 +322,8 @@ fun PaperizeApp(
|
||||
)
|
||||
),
|
||||
settingsViewModel = settingsViewModel,
|
||||
scheduler = scheduler
|
||||
scheduler = scheduler,
|
||||
context = context
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -343,7 +349,8 @@ fun PaperizeApp(
|
||||
)
|
||||
),
|
||||
settingsViewModel = settingsViewModel,
|
||||
scheduler = scheduler
|
||||
scheduler = scheduler,
|
||||
context = context
|
||||
)
|
||||
}
|
||||
else if (albumState.value.selectedAlbum.isNotEmpty() && settingsState.value.wallpaperSettings.enableChanger) {
|
||||
@@ -355,7 +362,8 @@ fun PaperizeApp(
|
||||
)
|
||||
),
|
||||
settingsViewModel = settingsViewModel,
|
||||
scheduler = scheduler
|
||||
scheduler = scheduler,
|
||||
context = context
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -371,6 +379,7 @@ fun PaperizeApp(
|
||||
),
|
||||
settingsViewModel = settingsViewModel,
|
||||
scheduler = scheduler,
|
||||
context = context,
|
||||
changeImmediate = true,
|
||||
cancelImmediate = true,
|
||||
firstLaunch = true
|
||||
@@ -473,7 +482,8 @@ fun PaperizeApp(
|
||||
scheduleSettings = settingsState.value.scheduleSettings.copy(
|
||||
startTime = Pair(time.hour, time.minute))
|
||||
),
|
||||
scheduler = scheduler
|
||||
scheduler = scheduler,
|
||||
context = context
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -487,7 +497,8 @@ fun PaperizeApp(
|
||||
changeStartTime = changeStartTime
|
||||
)
|
||||
),
|
||||
scheduler = scheduler
|
||||
scheduler = scheduler,
|
||||
context = context
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -501,15 +512,23 @@ fun PaperizeApp(
|
||||
shuffle = shuffle
|
||||
)
|
||||
),
|
||||
scheduler = scheduler
|
||||
scheduler = scheduler,
|
||||
context = context
|
||||
)
|
||||
}
|
||||
},
|
||||
onRefreshChange = { refresh ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetRefresh(refresh))
|
||||
if (settingsState.value.wallpaperSettings.enableChanger) {
|
||||
scheduler.scheduleRefresh(refresh)
|
||||
WallpaperAlarmSchedulerImpl.scheduleRefresh(context, refresh)
|
||||
}
|
||||
},
|
||||
onSkipLandscapeChange = { skipLandscape ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetSkipLandscape(skipLandscape))
|
||||
},
|
||||
onSkipNonInteractiveChange = {
|
||||
skipNonInteractive ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetSkipNonInteractive(skipNonInteractive))
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -688,6 +707,7 @@ private fun CoroutineScope.scheduleWallpaperUpdate(
|
||||
settingsState: SettingsState,
|
||||
settingsViewModel: SettingsViewModel,
|
||||
scheduler: WallpaperAlarmSchedulerImpl,
|
||||
context: android.content.Context,
|
||||
refreshNextTime: Boolean = false,
|
||||
changeImmediate: Boolean = true,
|
||||
cancelImmediate: Boolean = true,
|
||||
@@ -720,7 +740,7 @@ private fun CoroutineScope.scheduleWallpaperUpdate(
|
||||
cancelImmediate = cancelImmediate,
|
||||
firstLaunch = firstLaunch
|
||||
)
|
||||
scheduler.scheduleRefresh(settingsState.scheduleSettings.refresh)
|
||||
WallpaperAlarmSchedulerImpl.scheduleRefresh(context, settingsState.scheduleSettings.refresh)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -728,6 +748,7 @@ private fun CoroutineScope.updateWallpaperAlarm(
|
||||
job: Job?,
|
||||
settingsState: SettingsState,
|
||||
scheduler: WallpaperAlarmSchedulerImpl,
|
||||
context: android.content.Context,
|
||||
firstLaunch: Boolean = true,
|
||||
): Job {
|
||||
job?.cancel()
|
||||
@@ -747,7 +768,7 @@ private fun CoroutineScope.updateWallpaperAlarm(
|
||||
wallpaperAlarmItem = alarmItem,
|
||||
firstLaunch = firstLaunch
|
||||
)
|
||||
scheduler.scheduleRefresh(settingsState.scheduleSettings.refresh)
|
||||
WallpaperAlarmSchedulerImpl.scheduleRefresh(context, settingsState.scheduleSettings.refresh)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-5
@@ -96,22 +96,25 @@ fun AddAlbumScreen(
|
||||
contract = ActivityResultContracts.OpenMultipleDocuments(),
|
||||
onResult = { uris: List<Uri> ->
|
||||
scope.launch(Dispatchers.IO) {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.SetLoading(true))
|
||||
withContext(Dispatchers.Main) {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.SetLoading(true))
|
||||
}
|
||||
val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
val uriList = uris.mapNotNull { uri ->
|
||||
try {
|
||||
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
||||
uri.toString()
|
||||
} catch (_: Exception) {
|
||||
} catch (e: Exception) {
|
||||
Log.e("AddAlbumScreen", "Failed to take persistable URI permission for image: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
if (uriList.isNotEmpty()) {
|
||||
withContext(Dispatchers.Main) {
|
||||
withContext(Dispatchers.Main) {
|
||||
if (uriList.isNotEmpty()) {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.AddWallpapers(uriList))
|
||||
}
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.SetLoading(false))
|
||||
}
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.SetLoading(false))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
+26
-13
@@ -94,19 +94,26 @@ fun AlbumViewScreen(
|
||||
onResult = remember(albumScreenViewModel, scope, context) {
|
||||
{ uris: List<Uri> ->
|
||||
scope.launch(Dispatchers.IO) {
|
||||
albumScreenViewModel.onEvent(AlbumViewEvent.SetLoading(true))
|
||||
withContext(Dispatchers.Main) {
|
||||
albumScreenViewModel.onEvent(AlbumViewEvent.SetLoading(true))
|
||||
}
|
||||
val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
val uriList = uris.mapNotNull { uri ->
|
||||
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
||||
val persistedUriPermissions = context.contentResolver.persistedUriPermissions
|
||||
if (persistedUriPermissions.any { it.uri == uri }) uri.toString() else null
|
||||
}
|
||||
if (uriList.isNotEmpty()) {
|
||||
withContext(Dispatchers.Main) {
|
||||
albumScreenViewModel.onEvent(AlbumViewEvent.AddWallpapers(uriList))
|
||||
try {
|
||||
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
||||
val persistedUriPermissions = context.contentResolver.persistedUriPermissions
|
||||
if (persistedUriPermissions.any { it.uri == uri }) uri.toString() else null
|
||||
} catch (e: Exception) {
|
||||
android.util.Log.e("AlbumViewScreen", "Failed to take persistable URI permission for image: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
albumScreenViewModel.onEvent(AlbumViewEvent.SetLoading(false))
|
||||
withContext(Dispatchers.Main) {
|
||||
if (uriList.isNotEmpty()) {
|
||||
albumScreenViewModel.onEvent(AlbumViewEvent.AddWallpapers(uriList))
|
||||
}
|
||||
albumScreenViewModel.onEvent(AlbumViewEvent.SetLoading(false))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,10 +127,16 @@ fun AlbumViewScreen(
|
||||
scope.launch(Dispatchers.IO) {
|
||||
val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
if (uri != null) {
|
||||
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
||||
val persistedUriPermissions = context.contentResolver.persistedUriPermissions
|
||||
if (persistedUriPermissions.any { it.uri == uri }) {
|
||||
albumScreenViewModel.onEvent(AlbumViewEvent.AddFolder(uri.toString()))
|
||||
try {
|
||||
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
||||
val persistedUriPermissions = context.contentResolver.persistedUriPermissions
|
||||
if (persistedUriPermissions.any { it.uri == uri }) {
|
||||
withContext(Dispatchers.Main) {
|
||||
albumScreenViewModel.onEvent(AlbumViewEvent.AddFolder(uri.toString()))
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
android.util.Log.e("AlbumViewScreen", "Failed to take persistable URI permission for folder: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -64,7 +64,9 @@ fun HomeScreen(
|
||||
onChangeStartTimeToggle: (Boolean) -> Unit,
|
||||
onStartTimeChange: (TimePickerState) -> Unit,
|
||||
onShuffleCheck: (Boolean) -> Unit,
|
||||
onRefreshChange: (Boolean) -> Unit
|
||||
onRefreshChange: (Boolean) -> Unit,
|
||||
onSkipLandscapeChange: (Boolean) -> Unit,
|
||||
onSkipNonInteractiveChange: (Boolean) -> Unit,
|
||||
) {
|
||||
val tabItems = getTabItems()
|
||||
val pagerState = rememberPagerState(0) { tabItems.size }
|
||||
@@ -142,7 +144,9 @@ fun HomeScreen(
|
||||
onChangeStartTimeToggle = onChangeStartTimeToggle,
|
||||
onStartTimeChange = onStartTimeChange,
|
||||
onShuffleCheck = onShuffleCheck,
|
||||
onRefreshChange = onRefreshChange
|
||||
onRefreshChange = onRefreshChange,
|
||||
onSkipLandscapeChange = onSkipLandscapeChange,
|
||||
onSkipNonInteractiveChange = onSkipNonInteractiveChange
|
||||
)
|
||||
else -> LibraryScreen(
|
||||
albums = albums,
|
||||
|
||||
+2
@@ -34,4 +34,6 @@ sealed class SettingsEvent {
|
||||
data class SetStartTime(val hour: Int, val minute: Int): SettingsEvent()
|
||||
data class SetShuffle(val shuffle: Boolean): SettingsEvent()
|
||||
data class SetRefresh(val refresh: Boolean): SettingsEvent()
|
||||
data class SetSkipLandscape(val skipLandscape: Boolean): SettingsEvent()
|
||||
data class SetSkipNonInteractive(val skipNonInteractive: Boolean): SettingsEvent()
|
||||
}
|
||||
+6
-2
@@ -40,7 +40,9 @@ data class SettingsState(
|
||||
val nextSetTime: String? = null,
|
||||
val changeStartTime: Boolean = false,
|
||||
val startTime: Pair<Int, Int> = Pair(0, 0),
|
||||
val refresh: Boolean = true
|
||||
val refresh: Boolean = true,
|
||||
val skipLandscape: Boolean = false,
|
||||
val skipNonInteractive: Boolean = false
|
||||
)
|
||||
|
||||
data class EffectSettings(
|
||||
@@ -77,6 +79,8 @@ data class SettingsState(
|
||||
val lockGrayscalePercentage: Int,
|
||||
val lockAlbumName: String,
|
||||
val homeAlbumName: String,
|
||||
val shuffle: Boolean
|
||||
val shuffle: Boolean,
|
||||
val skipLandscape: Boolean,
|
||||
val skipNonInteractive: Boolean
|
||||
)
|
||||
}
|
||||
+22
-3
@@ -108,7 +108,9 @@ class SettingsViewModel @Inject constructor(
|
||||
settingsDataStoreImpl.getIntFlow(SettingsConstants.START_HOUR),
|
||||
settingsDataStoreImpl.getIntFlow(SettingsConstants.START_MINUTE),
|
||||
settingsDataStoreImpl.getBooleanFlow(SettingsConstants.SHUFFLE),
|
||||
settingsDataStoreImpl.getBooleanFlow(SettingsConstants.REFRESH)
|
||||
settingsDataStoreImpl.getBooleanFlow(SettingsConstants.REFRESH),
|
||||
settingsDataStoreImpl.getBooleanFlow(SettingsConstants.SKIP_LANDSCAPE),
|
||||
settingsDataStoreImpl.getBooleanFlow(SettingsConstants.SKIP_NON_INTERACTIVE)
|
||||
) { flows ->
|
||||
ScheduleSettings(
|
||||
scheduleSeparately = flows[0] as Boolean? ?: false,
|
||||
@@ -119,7 +121,9 @@ class SettingsViewModel @Inject constructor(
|
||||
changeStartTime = flows[5] as Boolean? ?: false,
|
||||
startTime = Pair(flows[6] as Int? ?: 0, flows[7] as Int? ?: 0),
|
||||
shuffle = flows[8] as Boolean? ?: true,
|
||||
refresh = flows[9] as Boolean? ?: true
|
||||
refresh = flows[9] as Boolean? ?: true,
|
||||
skipLandscape = flows[10] as Boolean? ?: false,
|
||||
skipNonInteractive = flows[11] as Boolean? ?: false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -547,6 +551,19 @@ class SettingsViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetSkipLandscape -> {
|
||||
viewModelScope.launch {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.SKIP_LANDSCAPE, event.skipLandscape)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
is SettingsEvent.SetSkipNonInteractive -> {
|
||||
viewModelScope.launch {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.SKIP_NON_INTERACTIVE, event.skipNonInteractive)
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.Reset -> {
|
||||
viewModelScope.launch {
|
||||
val keysToDelete = listOf(
|
||||
@@ -589,7 +606,9 @@ class SettingsViewModel @Inject constructor(
|
||||
SettingsConstants.START_HOUR,
|
||||
SettingsConstants.START_MINUTE,
|
||||
SettingsConstants.SHUFFLE,
|
||||
SettingsConstants.REFRESH
|
||||
SettingsConstants.REFRESH,
|
||||
SettingsConstants.SKIP_LANDSCAPE,
|
||||
SettingsConstants.SKIP_NON_INTERACTIVE
|
||||
)
|
||||
settingsDataStoreImpl.clear(keysToDelete)
|
||||
}
|
||||
|
||||
+13
-1
@@ -46,6 +46,8 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.co
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.IndividualSchedulingAndToggleRow
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.RefreshSwitch
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.ShuffleSwitch
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.SkipLandscapeSwitch
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.SkipNonInteractiveSwitch
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.TimeSliders
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.VignetteSwitchAndSlider
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.WallpaperPreviewAndScale
|
||||
@@ -81,7 +83,9 @@ fun WallpaperScreen(
|
||||
onChangeStartTimeToggle: (Boolean) -> Unit,
|
||||
onStartTimeChange: (TimePickerState) -> Unit,
|
||||
onShuffleCheck: (Boolean) -> Unit,
|
||||
onRefreshChange: (Boolean) -> Unit
|
||||
onRefreshChange: (Boolean) -> Unit,
|
||||
onSkipLandscapeChange: (Boolean) -> Unit,
|
||||
onSkipNonInteractiveChange: (Boolean) -> Unit
|
||||
) {
|
||||
val shouldShowScreen = wallpaperSettings.setHomeWallpaper || wallpaperSettings.setLockWallpaper
|
||||
val shouldShowSettings = shouldShowScreen && homeSelectedAlbum != null && lockSelectedAlbum != null
|
||||
@@ -274,6 +278,14 @@ fun WallpaperScreen(
|
||||
refresh = scheduleSettings.refresh,
|
||||
onRefreshChange = onRefreshChange
|
||||
)
|
||||
SkipLandscapeSwitch(
|
||||
skipLandscape = scheduleSettings.skipLandscape,
|
||||
onSkipLandscapeChange = onSkipLandscapeChange
|
||||
)
|
||||
SkipNonInteractiveSwitch(
|
||||
skipNonInteractive = scheduleSettings.skipNonInteractive,
|
||||
onSkipNonInteractiveChange = onSkipNonInteractiveChange
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-12
@@ -104,17 +104,9 @@ fun BlurSwitchAndSlider(
|
||||
onCheckedChange = onBlurChange
|
||||
)
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = blur,
|
||||
enter = expandVertically(animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow)),
|
||||
exit = fadeOut(
|
||||
animationSpec = tween(
|
||||
durationMillis = 300,
|
||||
easing = LinearOutSlowInEasing
|
||||
)
|
||||
)
|
||||
) {
|
||||
// Show sliders when blur is enabled, regardless of animation setting
|
||||
if (blur) {
|
||||
val sliderContent = @Composable {
|
||||
Column(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
@@ -246,8 +238,27 @@ fun BlurSwitchAndSlider(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = blur,
|
||||
enter = expandVertically(animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow)),
|
||||
exit = fadeOut(
|
||||
animationSpec = tween(
|
||||
durationMillis = 300,
|
||||
easing = LinearOutSlowInEasing
|
||||
)
|
||||
)
|
||||
) {
|
||||
sliderContent()
|
||||
}
|
||||
} else {
|
||||
sliderContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ fun CurrentAndNextChange(
|
||||
Text(parts[1], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
else if (parts.size == 3) {
|
||||
Text(stringResource(R.string.next_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(stringResource(R.string.last_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[1] + ' ' + parts[2], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
@@ -98,7 +98,7 @@ fun CurrentAndNextChange(
|
||||
Text(parts[1], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
else if (parts.size == 3) {
|
||||
Text(stringResource(R.string.last_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(stringResource(R.string.next_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[1] + ' ' + parts[2], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
@Composable
|
||||
fun SkipLandscapeSwitch(
|
||||
skipLandscape: Boolean,
|
||||
onSkipLandscapeChange: (Boolean) -> Unit
|
||||
) {
|
||||
Surface(
|
||||
tonalElevation = 10.dp,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.skip_landscape_mode),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.W500
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.prevent_changing_during_landscape_mode),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
Switch(
|
||||
checked = skipLandscape,
|
||||
onCheckedChange = onSkipLandscapeChange
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
@Composable
|
||||
fun SkipNonInteractiveSwitch(
|
||||
skipNonInteractive: Boolean,
|
||||
onSkipNonInteractiveChange: (Boolean) -> Unit
|
||||
) {
|
||||
Surface(
|
||||
tonalElevation = 10.dp,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.skip_non_interactive_state),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.W500
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.prevent_changing_during_non_interactive_state),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
Switch(
|
||||
checked = skipNonInteractive,
|
||||
onCheckedChange = onSkipNonInteractiveChange
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+239
-224
@@ -1,18 +1,27 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager
|
||||
|
||||
import android.Manifest
|
||||
import android.app.AlarmManager
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.app.AlarmManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresPermission
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
import com.anthonyla.paperize.core.Type
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.MainActivity
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_service.HomeWallpaperService
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_service.LockWallpaperService
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.FormatStyle
|
||||
import javax.inject.Inject
|
||||
|
||||
data class ServiceConfig(
|
||||
@@ -27,19 +36,54 @@ sealed class WallpaperAction {
|
||||
data object UPDATE : WallpaperAction()
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is responsible for scheduling wallpaper alarms.
|
||||
* It uses the AlarmManager to schedule alarms for the [WallpaperReceiver].
|
||||
* It also uses [HomeWallpaperService] and [LockWallpaperService] to change the wallpaper due to receiver limitations.
|
||||
*/
|
||||
class WallpaperAlarmSchedulerImpl @Inject constructor(
|
||||
private val context: Context
|
||||
@param:ApplicationContext private val context: Context,
|
||||
private val settingsDataStore: SettingsDataStore
|
||||
): WallpaperAlarmScheduler {
|
||||
private val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
|
||||
/**
|
||||
* Schedules the wallpaper alarm based on the origin and changeImmediate
|
||||
*/
|
||||
companion object {
|
||||
private const val TAG = "WallpaperAlarmScheduler"
|
||||
|
||||
/**
|
||||
* Schedules a refresh alarm every 24hrs
|
||||
* This is a static method that doesn't require an instance of WallpaperAlarmSchedulerImpl
|
||||
*/
|
||||
fun scheduleRefresh(context: Context, refresh: Boolean = true) {
|
||||
Log.d(TAG, "scheduleRefresh called with refresh: $refresh")
|
||||
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
|
||||
// Cancel any existing refresh alarm
|
||||
val cancelIntent = Intent(context, WallpaperReceiver::class.java)
|
||||
val cancelPendingIntent = PendingIntent.getBroadcast(
|
||||
context,
|
||||
Type.REFRESH.ordinal,
|
||||
cancelIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
alarmManager.cancel(cancelPendingIntent)
|
||||
|
||||
if (refresh) {
|
||||
val intent = Intent(context, WallpaperReceiver::class.java).apply {
|
||||
putExtra("refresh", true)
|
||||
}
|
||||
val nextMidnight = LocalDateTime.now().plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0)
|
||||
Log.d(TAG, "Scheduling inexact repeating refresh alarm for next midnight: $nextMidnight")
|
||||
alarmManager.setInexactRepeating(
|
||||
AlarmManager.RTC_WAKEUP,
|
||||
nextMidnight.atZone(ZoneId.systemDefault()).toEpochSecond() * 1000,
|
||||
AlarmManager.INTERVAL_DAY,
|
||||
PendingIntent.getBroadcast(
|
||||
context,
|
||||
Type.REFRESH.ordinal,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresPermission(Manifest.permission.SCHEDULE_EXACT_ALARM)
|
||||
override suspend fun scheduleWallpaperAlarm(
|
||||
wallpaperAlarmItem: WallpaperAlarmItem,
|
||||
@@ -51,9 +95,14 @@ class WallpaperAlarmSchedulerImpl @Inject constructor(
|
||||
homeNextTime: String?,
|
||||
lockNextTime: String?,
|
||||
) {
|
||||
// Cancel previous alarms before setting new ones to prevent stale alarms
|
||||
if (cancelImmediate) cancelWallpaperAlarm()
|
||||
else {
|
||||
Log.d(TAG, "scheduleWallpaperAlarm called with:")
|
||||
Log.d(TAG, " - wallpaperAlarmItem: $wallpaperAlarmItem")
|
||||
Log.d(TAG, " - changeImmediate: $changeImmediate, setAlarm: $setAlarm, firstLaunch: $firstLaunch")
|
||||
|
||||
if (cancelImmediate) {
|
||||
Log.d(TAG, "Cancelling all previous alarms.")
|
||||
cancelWallpaperAlarm()
|
||||
} else {
|
||||
when (origin) {
|
||||
Type.HOME.ordinal -> cancelAlarm(Type.HOME)
|
||||
Type.LOCK.ordinal -> cancelAlarm(Type.LOCK)
|
||||
@@ -65,160 +114,174 @@ class WallpaperAlarmSchedulerImpl @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule new wallpaper alarm
|
||||
if (wallpaperAlarmItem.scheduleSeparately) {
|
||||
when (origin) {
|
||||
Type.LOCK.ordinal -> {
|
||||
if (changeImmediate) changeWallpaperImmediate(wallpaperAlarmItem, Type.LOCK)
|
||||
if (setAlarm) scheduleWallpaper(wallpaperAlarmItem, Type.LOCK, origin, firstLaunch, homeNextTime, lockNextTime)
|
||||
}
|
||||
Type.HOME.ordinal -> {
|
||||
if (changeImmediate) changeWallpaperImmediate(wallpaperAlarmItem, Type.HOME)
|
||||
if (setAlarm) scheduleWallpaper(wallpaperAlarmItem, Type.HOME, origin, firstLaunch, homeNextTime, lockNextTime)
|
||||
}
|
||||
null -> {
|
||||
if (changeImmediate) {
|
||||
changeWallpaperImmediate(wallpaperAlarmItem, Type.LOCK)
|
||||
changeWallpaperImmediate(wallpaperAlarmItem, Type.HOME)
|
||||
}
|
||||
if (setAlarm) {
|
||||
scheduleWallpaper(wallpaperAlarmItem, Type.LOCK, Type.LOCK.ordinal, firstLaunch, homeNextTime, lockNextTime)
|
||||
scheduleWallpaper(wallpaperAlarmItem, Type.HOME, Type.HOME.ordinal, firstLaunch, homeNextTime, lockNextTime)
|
||||
}
|
||||
}
|
||||
if (changeImmediate) {
|
||||
if (wallpaperAlarmItem.scheduleSeparately) {
|
||||
changeWallpaperImmediate(wallpaperAlarmItem, Type.LOCK)
|
||||
changeWallpaperImmediate(wallpaperAlarmItem, Type.HOME)
|
||||
} else {
|
||||
changeWallpaperImmediate(wallpaperAlarmItem, Type.SINGLE)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (changeImmediate) changeWallpaperImmediate(wallpaperAlarmItem, Type.SINGLE)
|
||||
if (setAlarm) scheduleWallpaper(wallpaperAlarmItem, Type.SINGLE, null, firstLaunch, homeNextTime, lockNextTime)
|
||||
|
||||
if (setAlarm) {
|
||||
if (wallpaperAlarmItem.scheduleSeparately) {
|
||||
scheduleWallpaper(wallpaperAlarmItem, Type.LOCK, Type.LOCK.ordinal, firstLaunch, homeNextTime, lockNextTime)
|
||||
scheduleWallpaper(wallpaperAlarmItem, Type.HOME, Type.HOME.ordinal, firstLaunch, homeNextTime, lockNextTime)
|
||||
} else {
|
||||
scheduleWallpaper(wallpaperAlarmItem, Type.SINGLE, null, firstLaunch, homeNextTime, lockNextTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the alarms
|
||||
*/
|
||||
override fun updateWallpaperAlarm(wallpaperAlarmItem: WallpaperAlarmItem, firstLaunch: Boolean) {
|
||||
cancelWallpaperAlarm()
|
||||
if (wallpaperAlarmItem.scheduleSeparately) {
|
||||
scheduleWallpaper(wallpaperAlarmItem, Type.LOCK, null, firstLaunch, "", "")
|
||||
scheduleWallpaper(wallpaperAlarmItem, Type.HOME, null, firstLaunch, "", "")
|
||||
}
|
||||
else {
|
||||
scheduleWallpaper(wallpaperAlarmItem, Type.SINGLE, null, firstLaunch, "", "")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the wallpaper without scheduling alarms
|
||||
*/
|
||||
override fun updateWallpaper(scheduleSeparately: Boolean, setHome: Boolean, setLock: Boolean) {
|
||||
if (scheduleSeparately) {
|
||||
updateWallpaper(Type.LOCK, setHome, setLock)
|
||||
updateWallpaper(Type.HOME, setHome, setLock)
|
||||
}
|
||||
else {
|
||||
updateWallpaper(Type.SINGLE, setHome, setLock)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels all active alarms
|
||||
*/
|
||||
override fun cancelWallpaperAlarm(cancelLock: Boolean, cancelHome: Boolean) {
|
||||
if (cancelLock) cancelAlarm(Type.LOCK)
|
||||
if (cancelHome) cancelAlarm(Type.HOME)
|
||||
if (cancelLock && cancelHome) {
|
||||
cancelAlarm(Type.SINGLE)
|
||||
cancelAlarm(Type.REFRESH)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules the wallpaper alarm based on type and time
|
||||
*/
|
||||
@RequiresPermission(Manifest.permission.SCHEDULE_EXACT_ALARM)
|
||||
private fun scheduleWallpaper(wallpaperAlarmItem: WallpaperAlarmItem, type: Type, origin: Int? = null, firstLaunch: Boolean = false, homeNextTime: String? = null, lockNextTime: String? = null) {
|
||||
private suspend fun scheduleWallpaper(
|
||||
wallpaperAlarmItem: WallpaperAlarmItem,
|
||||
type: Type,
|
||||
origin: Int? = null,
|
||||
firstLaunch: Boolean = false,
|
||||
homeNextTime: String? = null,
|
||||
lockNextTime: String? = null
|
||||
) {
|
||||
Log.d(TAG, "scheduleWallpaper called for type: $type")
|
||||
try {
|
||||
val nextTime = calculateNextAlarmTime(wallpaperAlarmItem, type, firstLaunch, homeNextTime ?: "", lockNextTime ?: "")
|
||||
Log.d(TAG, "Calculated next alarm time for type '$type': $nextTime")
|
||||
|
||||
val intent = createWallpaperIntent(wallpaperAlarmItem, type, origin)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
if (!alarmManager.canScheduleExactAlarms()) {
|
||||
cancelWallpaperAlarm()
|
||||
return
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !alarmManager.canScheduleExactAlarms()) {
|
||||
Log.w(TAG, "Cannot schedule exact alarms. Permission may be denied.")
|
||||
cancelWallpaperAlarm()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
scheduleExactAlarm(nextTime, intent)
|
||||
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
when (type) {
|
||||
Type.HOME -> settingsDataStore.putString(SettingsConstants.HOME_NEXT_SET_TIME, nextTime.toString())
|
||||
Type.LOCK -> settingsDataStore.putString(SettingsConstants.LOCK_NEXT_SET_TIME, nextTime.toString())
|
||||
Type.SINGLE -> {
|
||||
settingsDataStore.putString(SettingsConstants.HOME_NEXT_SET_TIME, nextTime.toString())
|
||||
settingsDataStore.putString(SettingsConstants.LOCK_NEXT_SET_TIME, nextTime.toString())
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
val currentHomeNext = settingsDataStore.getString(SettingsConstants.HOME_NEXT_SET_TIME)
|
||||
val currentLockNext = settingsDataStore.getString(SettingsConstants.LOCK_NEXT_SET_TIME)
|
||||
val nextHomeDateTime = runCatching { LocalDateTime.parse(currentHomeNext) }.getOrNull()
|
||||
val nextLockDateTime = runCatching { LocalDateTime.parse(currentLockNext) }.getOrNull()
|
||||
|
||||
val nextSetTimeForNotification = listOfNotNull(nextHomeDateTime, nextLockDateTime)
|
||||
.filter { it.isAfter(LocalDateTime.now()) }
|
||||
.minOrNull() ?: nextTime
|
||||
|
||||
settingsDataStore.putString(SettingsConstants.NEXT_SET_TIME, nextSetTimeForNotification.format(formatter))
|
||||
postNotification(nextSetTimeForNotification)
|
||||
|
||||
} catch (e: Exception) {
|
||||
Log.e("WallpaperAlarmScheduler", "Error scheduling wallpaper alarm: ${e.message}")
|
||||
Log.e(TAG, "Error scheduling wallpaper alarm for type '$type'", e)
|
||||
cancelWallpaperAlarm()
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateNextAlarmTime(wallpaperAlarmItem: WallpaperAlarmItem, type: Type, firstLaunch: Boolean, homeNextTime: String, lockNextTime: String): LocalDateTime {
|
||||
val startTime = LocalDateTime.now()
|
||||
private fun calculateNextAlarmTime(
|
||||
wallpaperAlarmItem: WallpaperAlarmItem,
|
||||
type: Type,
|
||||
firstLaunch: Boolean,
|
||||
homeNextTime: String,
|
||||
lockNextTime: String
|
||||
): LocalDateTime {
|
||||
val now = LocalDateTime.now()
|
||||
val intervalMinutes = when {
|
||||
type == Type.LOCK && wallpaperAlarmItem.scheduleSeparately -> wallpaperAlarmItem.lockInterval.toLong()
|
||||
else -> wallpaperAlarmItem.homeInterval.toLong()
|
||||
}
|
||||
|
||||
if (firstLaunch) {
|
||||
if (wallpaperAlarmItem.changeStartTime) {
|
||||
return startTime.withHour(wallpaperAlarmItem.startTime.first)
|
||||
.withMinute(wallpaperAlarmItem.startTime.second)
|
||||
.let { if (it.isBefore(startTime)) it.plusDays(1) else it }
|
||||
.withSecond(0)
|
||||
.withNano(0)
|
||||
val nextTime = if (wallpaperAlarmItem.changeStartTime) {
|
||||
var anchorTime = now
|
||||
.withHour(wallpaperAlarmItem.startTime.first)
|
||||
.withMinute(wallpaperAlarmItem.startTime.second)
|
||||
.withSecond(0).withNano(0)
|
||||
while (!anchorTime.isAfter(now)) {
|
||||
anchorTime = anchorTime.plusMinutes(intervalMinutes)
|
||||
}
|
||||
return when {
|
||||
type == Type.LOCK && wallpaperAlarmItem.scheduleSeparately ->
|
||||
startTime.plusMinutes(wallpaperAlarmItem.lockInterval.toLong()).withSecond(0).withNano(0)
|
||||
type == Type.HOME && wallpaperAlarmItem.scheduleSeparately ->
|
||||
startTime.plusMinutes(wallpaperAlarmItem.homeInterval.toLong()).withSecond(0).withNano(0).plusSeconds(10)
|
||||
else -> startTime.plusMinutes(wallpaperAlarmItem.homeInterval.toLong()).withSecond(0).withNano(0)
|
||||
anchorTime
|
||||
} else {
|
||||
if (firstLaunch) {
|
||||
now.plusMinutes(intervalMinutes)
|
||||
} else {
|
||||
val baseTime = when (type) {
|
||||
Type.LOCK -> runCatching { LocalDateTime.parse(lockNextTime) }.getOrDefault(now)
|
||||
else -> runCatching { LocalDateTime.parse(homeNextTime) }.getOrDefault(now)
|
||||
}
|
||||
var futureTime = baseTime.plusMinutes(intervalMinutes)
|
||||
while (!futureTime.isAfter(now)) {
|
||||
futureTime = futureTime.plusMinutes(intervalMinutes)
|
||||
}
|
||||
futureTime
|
||||
}
|
||||
}
|
||||
else {
|
||||
fun calculateFutureTime(baseTime: LocalDateTime, intervalMinutes: Long, addSeconds: Int = 0, depth: Int = 0): LocalDateTime {
|
||||
if (depth > 100) {
|
||||
return startTime.plusMinutes(intervalMinutes)
|
||||
}
|
||||
|
||||
var nextTime = baseTime.plusMinutes(intervalMinutes).withSecond(0).withNano(0)
|
||||
if (addSeconds > 0) nextTime = nextTime.plusSeconds(addSeconds.toLong())
|
||||
|
||||
return if (nextTime.isBefore(startTime)) {
|
||||
calculateFutureTime(nextTime, intervalMinutes, addSeconds, depth + 1)
|
||||
} else nextTime
|
||||
}
|
||||
|
||||
val nextTime = when {
|
||||
type == Type.LOCK && wallpaperAlarmItem.scheduleSeparately -> {
|
||||
val baseTime = try {
|
||||
if (lockNextTime.isEmpty()) startTime else LocalDateTime.parse(lockNextTime)
|
||||
} catch (e: Exception) {
|
||||
startTime
|
||||
}
|
||||
calculateFutureTime(baseTime, wallpaperAlarmItem.lockInterval.toLong())
|
||||
}
|
||||
type == Type.HOME && wallpaperAlarmItem.scheduleSeparately -> {
|
||||
val baseTime = try {
|
||||
if (homeNextTime.isEmpty()) startTime else LocalDateTime.parse(homeNextTime)
|
||||
} catch (e: Exception) {
|
||||
startTime
|
||||
}
|
||||
calculateFutureTime(baseTime, wallpaperAlarmItem.homeInterval.toLong(), 10)
|
||||
}
|
||||
else -> {
|
||||
val baseTime = try {
|
||||
if (homeNextTime.isEmpty()) startTime else LocalDateTime.parse(homeNextTime)
|
||||
} catch (e: Exception) {
|
||||
startTime
|
||||
}
|
||||
calculateFutureTime(baseTime, wallpaperAlarmItem.homeInterval.toLong())
|
||||
}
|
||||
}
|
||||
return nextTime.withSecond(0).withNano(0)
|
||||
return if (type == Type.HOME && wallpaperAlarmItem.scheduleSeparately) {
|
||||
nextTime.plusSeconds(10).withSecond(0).withNano(0)
|
||||
} else {
|
||||
nextTime.withSecond(0).withNano(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeWallpaperImmediate(wallpaperAlarmItem: WallpaperAlarmItem, type: Type) {
|
||||
Log.d(TAG, "changeWallpaperImmediate called for type: $type")
|
||||
val serviceConfig = ServiceConfig(
|
||||
homeInterval = wallpaperAlarmItem.homeInterval,
|
||||
lockInterval = wallpaperAlarmItem.lockInterval,
|
||||
scheduleSeparately = wallpaperAlarmItem.scheduleSeparately
|
||||
)
|
||||
|
||||
when (type.ordinal) {
|
||||
Type.SINGLE.ordinal -> {
|
||||
if (wallpaperAlarmItem.setLock) startService(context, LockWallpaperService::class.java, WallpaperAction.START, serviceConfig.copy(type = Type.SINGLE.ordinal))
|
||||
if (wallpaperAlarmItem.setHome) startService(context, HomeWallpaperService::class.java, WallpaperAction.START, serviceConfig.copy(type = Type.SINGLE.ordinal))
|
||||
}
|
||||
Type.LOCK.ordinal -> startService(context, LockWallpaperService::class.java, WallpaperAction.START, serviceConfig.copy(type = Type.LOCK.ordinal))
|
||||
Type.HOME.ordinal -> startService(context, HomeWallpaperService::class.java, WallpaperAction.START, serviceConfig.copy(type = Type.HOME.ordinal))
|
||||
}
|
||||
}
|
||||
|
||||
private fun startService(context: Context, serviceClass: Class<*>, action: WallpaperAction, config: ServiceConfig?) {
|
||||
Log.d(TAG, "startService for ${serviceClass.simpleName}, action: ${action.javaClass.simpleName}")
|
||||
val serviceIntent = Intent(context, serviceClass).apply {
|
||||
this.action = action.javaClass.simpleName
|
||||
config?.let {
|
||||
it.homeInterval?.let { interval -> putExtra("homeInterval", interval) }
|
||||
it.lockInterval?.let { interval -> putExtra("lockInterval", interval) }
|
||||
it.scheduleSeparately?.let { separate -> putExtra("scheduleSeparately", separate) }
|
||||
it.type?.let { type -> putExtra("type", type) }
|
||||
}
|
||||
}
|
||||
context.startForegroundService(serviceIntent)
|
||||
}
|
||||
|
||||
private fun postNotification(nextSetTime: LocalDateTime) {
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val formattedNextSetTime = nextSetTime.format(formatter)
|
||||
val mainActivityIntent = Intent(context, MainActivity::class.java)
|
||||
val pendingMainActivityIntent = PendingIntent.getActivity(
|
||||
context, 3, mainActivityIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
val notification = NotificationCompat.Builder(context, "wallpaper_service_channel").apply {
|
||||
setContentTitle(context.getString(R.string.app_name))
|
||||
setContentText(context.getString(R.string.next_wallpaper_change, formattedNextSetTime))
|
||||
setSmallIcon(R.drawable.notification_icon)
|
||||
setContentIntent(pendingMainActivityIntent)
|
||||
priority = NotificationCompat.PRIORITY_DEFAULT
|
||||
setOnlyAlertOnce(true)
|
||||
}.build()
|
||||
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.notify(1, notification)
|
||||
}
|
||||
|
||||
private fun createWallpaperIntent(wallpaperAlarmItem: WallpaperAlarmItem, type: Type, origin: Int?): Intent {
|
||||
return Intent(context, WallpaperReceiver::class.java).apply {
|
||||
putExtra("homeInterval", wallpaperAlarmItem.homeInterval)
|
||||
@@ -229,88 +292,30 @@ class WallpaperAlarmSchedulerImpl @Inject constructor(
|
||||
putExtra("origin", origin)
|
||||
putExtra("type", type.ordinal)
|
||||
putExtra("changeStartTime", wallpaperAlarmItem.changeStartTime)
|
||||
putExtra("startTime", intArrayOf(wallpaperAlarmItem.startTime.first, wallpaperAlarmItem.startTime.second))
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresPermission(Manifest.permission.SCHEDULE_EXACT_ALARM)
|
||||
private fun scheduleExactAlarm(nextTime: LocalDateTime, intent: Intent) {
|
||||
val requestCode = intent.getIntExtra("type", 0)
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
context,
|
||||
intent.getIntExtra("type", 0),
|
||||
requestCode,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
val triggerAtMillis = nextTime.atZone(ZoneId.systemDefault()).toEpochSecond() * 1000
|
||||
Log.d(TAG, "Setting exact alarm for $nextTime (Millis: $triggerAtMillis) with requestCode: $requestCode")
|
||||
alarmManager.setExactAndAllowWhileIdle(
|
||||
AlarmManager.RTC_WAKEUP,
|
||||
nextTime.atZone(ZoneId.systemDefault()).toEpochSecond() * 1000,
|
||||
triggerAtMillis,
|
||||
pendingIntent
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a refresh alarm every 24hrs
|
||||
*/
|
||||
fun scheduleRefresh(refresh: Boolean = true) {
|
||||
cancelAlarm(Type.REFRESH)
|
||||
if (refresh) {
|
||||
val intent = Intent(context, WallpaperReceiver::class.java).apply {
|
||||
putExtra("refresh", true)
|
||||
}
|
||||
val nextMidnight = LocalDateTime.now().plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0)
|
||||
alarmManager.setInexactRepeating(
|
||||
AlarmManager.RTC_WAKEUP,
|
||||
nextMidnight.atZone(ZoneId.systemDefault()).toEpochSecond() * 1000,
|
||||
AlarmManager.INTERVAL_DAY,
|
||||
PendingIntent.getBroadcast(
|
||||
context,
|
||||
Type.REFRESH.ordinal,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the service to change the wallpaper
|
||||
*/
|
||||
private fun changeWallpaperImmediate(wallpaperAlarmItem: WallpaperAlarmItem, type: Type) {
|
||||
when (type.ordinal) {
|
||||
Type.SINGLE.ordinal -> {
|
||||
if (wallpaperAlarmItem.setLock) startService(context, LockWallpaperService::class.java, WallpaperAction.START, ServiceConfig(wallpaperAlarmItem.homeInterval, wallpaperAlarmItem.lockInterval, wallpaperAlarmItem.scheduleSeparately, Type.SINGLE.ordinal))
|
||||
if (wallpaperAlarmItem.setHome) startService(context, HomeWallpaperService::class.java, WallpaperAction.START, ServiceConfig(wallpaperAlarmItem.homeInterval, wallpaperAlarmItem.lockInterval, wallpaperAlarmItem.scheduleSeparately, Type.SINGLE.ordinal))
|
||||
}
|
||||
Type.LOCK.ordinal -> {
|
||||
startService(context, LockWallpaperService::class.java, WallpaperAction.START, ServiceConfig(wallpaperAlarmItem.homeInterval, wallpaperAlarmItem.lockInterval, wallpaperAlarmItem.scheduleSeparately, Type.LOCK.ordinal))
|
||||
}
|
||||
Type.HOME.ordinal -> {
|
||||
startService(context, HomeWallpaperService::class.java, WallpaperAction.START, ServiceConfig(wallpaperAlarmItem.homeInterval, wallpaperAlarmItem.lockInterval, wallpaperAlarmItem.scheduleSeparately, Type.HOME.ordinal))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the wallpaper without changing the alarm
|
||||
*/
|
||||
private fun updateWallpaper(type: Type, setHome: Boolean, setLock: Boolean) {
|
||||
when (type.ordinal) {
|
||||
Type.SINGLE.ordinal -> {
|
||||
if (setLock) startService(context, LockWallpaperService::class.java, WallpaperAction.UPDATE)
|
||||
if (setHome) startService(context, HomeWallpaperService::class.java, WallpaperAction.UPDATE)
|
||||
}
|
||||
Type.LOCK.ordinal -> {
|
||||
startService(context, LockWallpaperService::class.java, WallpaperAction.UPDATE)
|
||||
}
|
||||
Type.HOME.ordinal -> {
|
||||
startService(context, HomeWallpaperService::class.java, WallpaperAction.UPDATE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the alarm based on type
|
||||
*/
|
||||
private fun cancelAlarm(type: Type) {
|
||||
Log.d(TAG, "Cancelling alarm for type: $type (requestCode: ${type.ordinal})")
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
context,
|
||||
type.ordinal,
|
||||
@@ -320,24 +325,34 @@ class WallpaperAlarmSchedulerImpl @Inject constructor(
|
||||
alarmManager.cancel(pendingIntent)
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the service to change the wallpaper
|
||||
*/
|
||||
private fun startService(
|
||||
context: Context,
|
||||
serviceClass: Class<*>,
|
||||
action: WallpaperAction,
|
||||
config: ServiceConfig? = null
|
||||
) {
|
||||
val serviceIntent = Intent(context, serviceClass).apply {
|
||||
this.action = action::class.java.simpleName
|
||||
config?.let {
|
||||
it.homeInterval?.let { interval -> putExtra("homeInterval", interval) }
|
||||
it.lockInterval?.let { interval -> putExtra("lockInterval", interval) }
|
||||
it.scheduleSeparately?.let { separate -> putExtra("scheduleSeparately", separate) }
|
||||
it.type?.let { type -> putExtra("type", type) }
|
||||
override fun updateWallpaperAlarm(wallpaperAlarmItem: WallpaperAlarmItem, firstLaunch: Boolean) {}
|
||||
|
||||
override fun updateWallpaper(scheduleSeparately: Boolean, setHome: Boolean, setLock: Boolean) {
|
||||
if (scheduleSeparately) {
|
||||
updateWallpaper(Type.LOCK, setHome, setLock)
|
||||
updateWallpaper(Type.HOME, setHome, setLock)
|
||||
} else {
|
||||
updateWallpaper(Type.SINGLE, setHome, setLock)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateWallpaper(type: Type, setHome: Boolean, setLock: Boolean) {
|
||||
when (type.ordinal) {
|
||||
Type.SINGLE.ordinal -> {
|
||||
if (setLock) startService(context, LockWallpaperService::class.java, WallpaperAction.UPDATE, null)
|
||||
if (setHome) startService(context, HomeWallpaperService::class.java, WallpaperAction.UPDATE, null)
|
||||
}
|
||||
Type.LOCK.ordinal -> startService(context, LockWallpaperService::class.java, WallpaperAction.UPDATE, null)
|
||||
Type.HOME.ordinal -> startService(context, HomeWallpaperService::class.java, WallpaperAction.UPDATE, null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun cancelWallpaperAlarm(cancelLock: Boolean, cancelHome: Boolean) {
|
||||
if (cancelLock) cancelAlarm(Type.LOCK)
|
||||
if (cancelHome) cancelAlarm(Type.HOME)
|
||||
if (cancelLock && cancelHome) {
|
||||
cancelAlarm(Type.SINGLE)
|
||||
cancelAlarm(Type.REFRESH)
|
||||
}
|
||||
context.startService(serviceIntent)
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -35,7 +35,7 @@ class WallpaperBootAndChangeReceiver : BroadcastReceiver() {
|
||||
Intent.ACTION_TIMEZONE_CHANGED,
|
||||
ACTION_SHORTCUT -> {
|
||||
saveExecutionTime(context)
|
||||
val scheduler = WallpaperAlarmSchedulerImpl(context)
|
||||
val scheduler = WallpaperAlarmSchedulerImpl(context, settingsDataStoreImpl)
|
||||
val toggleChanger = settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: false
|
||||
val selectedAlbum = settingsDataStoreImpl.getString(SettingsConstants.HOME_ALBUM_NAME) ?: settingsDataStoreImpl.getString(SettingsConstants.LOCK_ALBUM_NAME) ?: ""
|
||||
|
||||
@@ -64,7 +64,7 @@ class WallpaperBootAndChangeReceiver : BroadcastReceiver() {
|
||||
lockNextTime = settingsDataStoreImpl.getString(SettingsConstants.LOCK_NEXT_SET_TIME),
|
||||
)
|
||||
}
|
||||
scheduler.scheduleRefresh(refresh)
|
||||
WallpaperAlarmSchedulerImpl.scheduleRefresh(context, refresh)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+55
-33
@@ -3,6 +3,7 @@ package com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
import com.anthonyla.paperize.core.SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
import com.anthonyla.paperize.core.Type
|
||||
@@ -13,33 +14,39 @@ import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.FormatStyle
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Receiver for the alarm manager to change wallpaper
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
class WallpaperReceiver : BroadcastReceiver() {
|
||||
@Inject
|
||||
lateinit var settingsDataStoreImpl: SettingsDataStore
|
||||
lateinit var settingsDataStore: SettingsDataStore
|
||||
|
||||
companion object {
|
||||
private const val TAG = "WallpaperReceiver"
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
if (context != null) {
|
||||
val refresh = intent?.getBooleanExtra("refresh", false)
|
||||
if (refresh == true) {
|
||||
Log.d(TAG, "onReceive triggered.")
|
||||
if (context != null && intent != null) {
|
||||
val refresh = intent.getBooleanExtra("refresh", false)
|
||||
if (refresh) {
|
||||
val serviceIntent = Intent(context, HomeWallpaperService::class.java).apply {
|
||||
action = HomeWallpaperService.Actions.REFRESH.toString()
|
||||
}
|
||||
context.startService(serviceIntent)
|
||||
}
|
||||
else {
|
||||
val homeInterval = intent?.getIntExtra("homeInterval", WALLPAPER_CHANGE_INTERVAL_DEFAULT) ?: WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
val lockInterval = intent?.getIntExtra("lockInterval", WALLPAPER_CHANGE_INTERVAL_DEFAULT) ?: WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
val scheduleSeparately = intent?.getBooleanExtra("scheduleSeparately", false) ?: false
|
||||
val type = intent?.getIntExtra("type", Type.SINGLE.ordinal) ?: Type.SINGLE.ordinal
|
||||
val setHome = intent?.getBooleanExtra("setHome", false) ?: false
|
||||
val setLock = intent?.getBooleanExtra("setLock", false) ?: false
|
||||
val changeStartTime = intent?.getBooleanExtra("changeStartTime", false) ?: false
|
||||
val startTime = intent?.getIntArrayExtra("startTime") ?: intArrayOf(0, 0)
|
||||
context.startForegroundService(serviceIntent)
|
||||
} else {
|
||||
Log.d(TAG, "Regular wallpaper change alarm received.")
|
||||
val homeInterval = intent.getIntExtra("homeInterval", WALLPAPER_CHANGE_INTERVAL_DEFAULT)
|
||||
val lockInterval = intent.getIntExtra("lockInterval", WALLPAPER_CHANGE_INTERVAL_DEFAULT)
|
||||
val scheduleSeparately = intent.getBooleanExtra("scheduleSeparately", false)
|
||||
val type = intent.getIntExtra("type", Type.SINGLE.ordinal)
|
||||
val setHome = intent.getBooleanExtra("setHome", false)
|
||||
val setLock = intent.getBooleanExtra("setLock", false)
|
||||
val changeStartTime = intent.getBooleanExtra("changeStartTime", false)
|
||||
val startTime = intent.getIntArrayExtra("startTime") ?: intArrayOf(0, 0)
|
||||
|
||||
when (type) {
|
||||
Type.SINGLE.ordinal -> {
|
||||
@@ -54,29 +61,44 @@ class WallpaperReceiver : BroadcastReceiver() {
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule next alarm for next wallpaper change
|
||||
val origin = intent?.getIntExtra("origin", -1)?.takeIf { it != -1 }
|
||||
val origin = intent.getIntExtra("origin", -1).takeIf { it != -1 }
|
||||
Log.d(TAG, "Rescheduling next alarm from receiver with origin: $origin")
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
WallpaperAlarmSchedulerImpl(context).scheduleWallpaperAlarm(
|
||||
wallpaperAlarmItem = WallpaperAlarmItem(
|
||||
homeInterval = homeInterval,
|
||||
lockInterval = lockInterval,
|
||||
scheduleSeparately = scheduleSeparately,
|
||||
setHome = setHome,
|
||||
setLock = setLock,
|
||||
changeStartTime = changeStartTime,
|
||||
startTime = Pair(startTime[0], startTime[1]),
|
||||
),
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val currentTime = LocalDateTime.now()
|
||||
settingsDataStore.putString(SettingsConstants.LAST_SET_TIME, currentTime.format(formatter))
|
||||
|
||||
|
||||
val homeNext = settingsDataStore.getString(SettingsConstants.HOME_NEXT_SET_TIME)
|
||||
val lockNext = settingsDataStore.getString(SettingsConstants.LOCK_NEXT_SET_TIME)
|
||||
|
||||
val alarmItem = WallpaperAlarmItem(
|
||||
homeInterval = homeInterval,
|
||||
lockInterval = lockInterval,
|
||||
scheduleSeparately = scheduleSeparately,
|
||||
setHome = setHome,
|
||||
setLock = setLock,
|
||||
changeStartTime = changeStartTime,
|
||||
startTime = Pair(startTime[0], startTime[1]),
|
||||
)
|
||||
|
||||
val scheduler = WallpaperAlarmSchedulerImpl(context, settingsDataStore)
|
||||
scheduler.scheduleWallpaperAlarm(
|
||||
wallpaperAlarmItem = alarmItem,
|
||||
origin = origin,
|
||||
homeNextTime = settingsDataStoreImpl.getString(SettingsConstants.HOME_NEXT_SET_TIME),
|
||||
lockNextTime = settingsDataStoreImpl.getString(SettingsConstants.LOCK_NEXT_SET_TIME),
|
||||
changeImmediate = false,
|
||||
cancelImmediate = false,
|
||||
setAlarm = true,
|
||||
firstLaunch = false,
|
||||
homeNextTime = homeNext,
|
||||
lockNextTime = lockNext,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startService(context: Context, serviceClass: Class<*>, action: String, homeInterval: Int? = null, lockInterval: Int? = null, scheduleSeparately: Boolean? = null, type: Int? = null) {
|
||||
private fun startService(context: Context, serviceClass: Class<*>, action: String, homeInterval: Int?, lockInterval: Int?, scheduleSeparately: Boolean?, type: Int?) {
|
||||
val serviceIntent = Intent(context, serviceClass).apply {
|
||||
this.action = action
|
||||
homeInterval?.let { putExtra("homeInterval", it) }
|
||||
|
||||
+188
-211
@@ -1,7 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.wallpaper_service
|
||||
|
||||
import android.Manifest
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
import android.app.WallpaperManager
|
||||
@@ -12,46 +11,27 @@ import android.net.Uri
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.os.IBinder
|
||||
import android.os.PowerManager
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresPermission
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.core.ScalingConstants
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
import com.anthonyla.paperize.core.Type
|
||||
import com.anthonyla.paperize.core.decompress
|
||||
import com.anthonyla.paperize.core.findFirstValidUri
|
||||
import com.anthonyla.paperize.core.getDeviceScreenSize
|
||||
import com.anthonyla.paperize.core.getFolderMetadata
|
||||
import com.anthonyla.paperize.core.getWallpaperFromFolder
|
||||
import com.anthonyla.paperize.core.isDirectory
|
||||
import com.anthonyla.paperize.core.isValidUri
|
||||
import com.anthonyla.paperize.core.processBitmap
|
||||
import com.anthonyla.paperize.core.retrieveBitmap
|
||||
import com.anthonyla.paperize.core.*
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.MainActivity
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
||||
import com.anthonyla.paperize.feature.wallpaper.tasker_shortcut.triggerWallpaperTaskerEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperBootAndChangeReceiver
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.FormatStyle
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Service for changing home screen
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
class HomeWallpaperService: Service() {
|
||||
private val handleThread = HandlerThread("HomeThread")
|
||||
@@ -62,6 +42,7 @@ class HomeWallpaperService: Service() {
|
||||
private var homeInterval: Int = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
private var lockInterval: Int = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
private var type = Type.SINGLE.ordinal
|
||||
private var isForeground = false
|
||||
|
||||
enum class Actions {
|
||||
START,
|
||||
@@ -69,14 +50,17 @@ class HomeWallpaperService: Service() {
|
||||
REFRESH
|
||||
}
|
||||
|
||||
override fun onBind(p0: Intent?): IBinder? {
|
||||
return null
|
||||
}
|
||||
override fun onBind(p0: Intent?): IBinder? = null
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
handleThread.start()
|
||||
workerHandler = Handler(handleThread.looper)
|
||||
if (!isForeground) {
|
||||
val notification = createInitialNotification()
|
||||
startForeground(1, notification)
|
||||
isForeground = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
@@ -89,12 +73,8 @@ class HomeWallpaperService: Service() {
|
||||
type = intent.getIntExtra("type", Type.SINGLE.ordinal)
|
||||
workerTaskStart()
|
||||
}
|
||||
Actions.UPDATE.toString() -> {
|
||||
workerTaskUpdate()
|
||||
}
|
||||
Actions.REFRESH.toString() -> {
|
||||
workerTaskRefresh()
|
||||
}
|
||||
Actions.UPDATE.toString() -> workerTaskUpdate()
|
||||
Actions.REFRESH.toString() -> workerTaskRefresh()
|
||||
}
|
||||
}
|
||||
return START_NOT_STICKY
|
||||
@@ -134,38 +114,18 @@ class HomeWallpaperService: Service() {
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a notification for the wallpaper service
|
||||
private fun createNotification(nextSetTime: LocalDateTime?): android.app.Notification? {
|
||||
nextSetTime?.let {
|
||||
val changeWallpaperIntent = Intent(this, WallpaperBootAndChangeReceiver::class.java).apply {
|
||||
action = "com.anthonyla.paperize.SHORTCUT"
|
||||
}
|
||||
val pendingChangeWallpaperIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
changeWallpaperIntent,
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
val mainActivityIntent = Intent(this, MainActivity::class.java)
|
||||
val pendingMainActivityIntent = PendingIntent.getActivity(
|
||||
this,
|
||||
3,
|
||||
mainActivityIntent,
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val formattedNextSetTime = nextSetTime.format(formatter)
|
||||
return NotificationCompat.Builder(this, "wallpaper_service_channel").apply {
|
||||
setContentTitle(getString(R.string.app_name))
|
||||
setContentText(getString(R.string.next_wallpaper_change, formattedNextSetTime))
|
||||
setSmallIcon(R.drawable.notification_icon)
|
||||
setContentIntent(pendingMainActivityIntent)
|
||||
addAction(R.drawable.notification_icon, getString(R.string.change_wallpaper), pendingChangeWallpaperIntent)
|
||||
priority = NotificationCompat.PRIORITY_DEFAULT
|
||||
setAutoCancel(true)
|
||||
}.build()
|
||||
}
|
||||
return null
|
||||
private fun createInitialNotification(): android.app.Notification {
|
||||
val mainActivityIntent = Intent(this, MainActivity::class.java)
|
||||
val pendingMainActivityIntent = PendingIntent.getActivity(
|
||||
this, 3, mainActivityIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
return NotificationCompat.Builder(this, "wallpaper_service_channel").apply {
|
||||
setContentTitle(getString(R.string.app_name))
|
||||
setContentText(getString(R.string.changing_wallpaper))
|
||||
setSmallIcon(R.drawable.notification_icon)
|
||||
setContentIntent(pendingMainActivityIntent)
|
||||
priority = NotificationCompat.PRIORITY_DEFAULT
|
||||
}.build()
|
||||
}
|
||||
|
||||
private suspend fun getWallpaperSettings(): SettingsState.ServiceSettings {
|
||||
@@ -188,14 +148,12 @@ class HomeWallpaperService: Service() {
|
||||
lockGrayscalePercentage = settingsDataStoreImpl.getInt(SettingsConstants.LOCK_GRAYSCALE_PERCENTAGE) ?: 0,
|
||||
lockAlbumName = settingsDataStoreImpl.getString(SettingsConstants.LOCK_ALBUM_NAME) ?: "",
|
||||
homeAlbumName = settingsDataStoreImpl.getString(SettingsConstants.HOME_ALBUM_NAME) ?: "",
|
||||
shuffle = settingsDataStoreImpl.getBoolean(SettingsConstants.SHUFFLE) ?: true
|
||||
shuffle = settingsDataStoreImpl.getBoolean(SettingsConstants.SHUFFLE) ?: true,
|
||||
skipLandscape = settingsDataStoreImpl.getBoolean(SettingsConstants.SKIP_LANDSCAPE) ?: false,
|
||||
skipNonInteractive = settingsDataStoreImpl.getBoolean(SettingsConstants.SKIP_NON_INTERACTIVE) ?: false
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the wallpaper to the next wallpaper in the queue of the selected album
|
||||
* If none left, reshuffle the wallpapers and pick the first one
|
||||
*/
|
||||
private suspend fun changeWallpaper(context: Context) {
|
||||
try {
|
||||
var selectedAlbum = albumRepository.getSelectedAlbums().first()
|
||||
@@ -208,13 +166,29 @@ class HomeWallpaperService: Service() {
|
||||
onDestroy()
|
||||
return
|
||||
}
|
||||
|
||||
if (settings.skipLandscape && context.resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
|
||||
Log.d("PaperizeWallpaperChanger", "Skipping wallpaper change - device is in landscape mode")
|
||||
onDestroy()
|
||||
return
|
||||
}
|
||||
|
||||
if (settings.skipNonInteractive){
|
||||
val powerManager = context.getSystemService(POWER_SERVICE) as PowerManager
|
||||
if (!powerManager.isInteractive){
|
||||
Log.d(
|
||||
"PaperizeWallpaperChanger", "Skipping wallpaper change - device is in non-interactive state")
|
||||
onDestroy()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var homeAlbum = selectedAlbum.find { it.album.initialAlbumName == settings.homeAlbumName }
|
||||
if (homeAlbum == null) {
|
||||
onDestroy()
|
||||
return
|
||||
}
|
||||
when {
|
||||
// Case: Set home and lock screen wallpapers using separate albums (home screen and lock screen album)
|
||||
settings.setHome && settings.setLock && scheduleSeparately -> {
|
||||
var wallpaper = homeAlbum.album.homeWallpapersInQueue.firstOrNull()
|
||||
if (wallpaper == null) {
|
||||
@@ -306,7 +280,6 @@ class HomeWallpaperService: Service() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Case: Set home and lock screen wallpapers using the same album (home screen album)
|
||||
settings.setHome && settings.setLock && !scheduleSeparately -> {
|
||||
var wallpaper = homeAlbum.album.homeWallpapersInQueue.firstOrNull()
|
||||
if (wallpaper == null) {
|
||||
@@ -396,7 +369,6 @@ class HomeWallpaperService: Service() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Case: Set home screen wallpaper (home screen album)
|
||||
settings.setHome -> {
|
||||
var wallpaper = homeAlbum.album.homeWallpapersInQueue.firstOrNull()
|
||||
if (wallpaper == null) {
|
||||
@@ -485,44 +457,12 @@ class HomeWallpaperService: Service() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run notification
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val currentTime = LocalDateTime.now()
|
||||
val homeNextSetTime: LocalDateTime = currentTime.plusMinutes(homeInterval.toLong())
|
||||
val lockNextSetTime: LocalDateTime = try {
|
||||
LocalDateTime.parse(settingsDataStoreImpl.getString(SettingsConstants.LOCK_NEXT_SET_TIME))
|
||||
} catch (e: Exception) {
|
||||
currentTime
|
||||
}
|
||||
val nextSetTime: LocalDateTime = when {
|
||||
homeInterval == lockInterval -> homeNextSetTime
|
||||
settings.setHome && settings.setLock && scheduleSeparately -> {
|
||||
if (homeNextSetTime.isBefore(lockNextSetTime) && homeNextSetTime.isAfter(currentTime)) {
|
||||
homeNextSetTime
|
||||
} else lockNextSetTime
|
||||
}
|
||||
else -> homeNextSetTime
|
||||
}
|
||||
|
||||
nextSetTime.let {
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, currentTime.format(formatter))
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, it.format(formatter))
|
||||
settingsDataStoreImpl.putString(SettingsConstants.HOME_NEXT_SET_TIME, homeNextSetTime.toString())
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LOCK_NEXT_SET_TIME, lockNextSetTime.toString())
|
||||
}
|
||||
|
||||
val notification = createNotification(nextSetTime)
|
||||
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
notification?.let { notificationManager.notify(1, it) }
|
||||
Log.d("HomeWallpaperService", "Wallpaper change task completed.")
|
||||
} catch (e: Exception) {
|
||||
Log.e("PaperizeWallpaperChanger", "Error in changing wallpaper", e)
|
||||
Log.e("PaperizeWallpaperChanger", "Error in changing wallpaper (Home)", e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current wallpaper with current settings
|
||||
*/
|
||||
private suspend fun updateCurrentWallpaper(context: Context) {
|
||||
try {
|
||||
val selectedAlbum = albumRepository.getSelectedAlbums().first()
|
||||
@@ -537,27 +477,47 @@ class HomeWallpaperService: Service() {
|
||||
}
|
||||
|
||||
val currentHomeWallpaper = settingsDataStoreImpl.getString(SettingsConstants.CURRENT_HOME_WALLPAPER) ?: ""
|
||||
setWallpaper(
|
||||
context = context,
|
||||
wallpaper = currentHomeWallpaper.decompress("content://com.android.externalstorage.documents/").toUri(),
|
||||
darken = settings.darken,
|
||||
darkenPercent = settings.homeDarkenPercentage,
|
||||
scaling = settings.scaling,
|
||||
blur = settings.blur,
|
||||
blurPercent = settings.homeBlurPercentage,
|
||||
vignette = settings.vignette,
|
||||
vignettePercent = settings.homeVignettePercentage,
|
||||
grayscale = settings.grayscale,
|
||||
grayscalePercent = settings.homeGrayscalePercentage
|
||||
)
|
||||
val currentLockWallpaper = settingsDataStoreImpl.getString(SettingsConstants.CURRENT_LOCK_WALLPAPER) ?: ""
|
||||
|
||||
val bothEnabled = settings.setHome && settings.setLock && currentHomeWallpaper == currentLockWallpaper
|
||||
|
||||
if (bothEnabled) {
|
||||
setWallpaper(
|
||||
context = context,
|
||||
wallpaper = currentHomeWallpaper.decompress("content://com.android.externalstorage.documents/").toUri(),
|
||||
darken = settings.darken,
|
||||
darkenPercent = settings.homeDarkenPercentage,
|
||||
scaling = settings.scaling,
|
||||
blur = settings.blur,
|
||||
blurPercent = settings.homeBlurPercentage,
|
||||
vignette = settings.vignette,
|
||||
vignettePercent = settings.homeVignettePercentage,
|
||||
grayscale = settings.grayscale,
|
||||
grayscalePercent = settings.homeGrayscalePercentage,
|
||||
both = true
|
||||
)
|
||||
} else {
|
||||
if (settings.setHome) {
|
||||
setWallpaper(
|
||||
context = context,
|
||||
wallpaper = currentHomeWallpaper.decompress("content://com.android.externalstorage.documents/").toUri(),
|
||||
darken = settings.darken,
|
||||
darkenPercent = settings.homeDarkenPercentage,
|
||||
scaling = settings.scaling,
|
||||
blur = settings.blur,
|
||||
blurPercent = settings.homeBlurPercentage,
|
||||
vignette = settings.vignette,
|
||||
vignettePercent = settings.homeVignettePercentage,
|
||||
grayscale = settings.grayscale,
|
||||
grayscalePercent = settings.homeGrayscalePercentage
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("PaperizeWallpaperChanger", "Error in updating", e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the wallpaper to the given uri
|
||||
*/
|
||||
private fun setWallpaper(
|
||||
context: Context,
|
||||
wallpaper: Uri?,
|
||||
@@ -579,9 +539,36 @@ class HomeWallpaperService: Service() {
|
||||
val bitmap = retrieveBitmap(context, wallpaper, size.width, size.height, scaling)
|
||||
if (bitmap == null) return false
|
||||
else if (wallpaperManager.isSetWallpaperAllowed) {
|
||||
processBitmap(size.width, size.height, bitmap, darken, darkenPercent, scaling, blur, blurPercent, vignette, vignettePercent, grayscale, grayscalePercent)?.let { image ->
|
||||
if (both) setWallpaperSafely(image, WallpaperManager.FLAG_LOCK, wallpaperManager)
|
||||
setWallpaperSafely(image, WallpaperManager.FLAG_SYSTEM, wallpaperManager)
|
||||
if (both) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val settings = getWallpaperSettings()
|
||||
|
||||
processBitmap(
|
||||
size.width, size.height, bitmap,
|
||||
settings.darken, settings.homeDarkenPercentage,
|
||||
scaling,
|
||||
settings.blur, settings.homeBlurPercentage,
|
||||
settings.vignette, settings.homeVignettePercentage,
|
||||
settings.grayscale, settings.homeGrayscalePercentage
|
||||
)?.let { homeImage ->
|
||||
setWallpaperSafely(homeImage, WallpaperManager.FLAG_SYSTEM, wallpaperManager)
|
||||
}
|
||||
|
||||
processBitmap(
|
||||
size.width, size.height, bitmap,
|
||||
settings.darken, settings.lockDarkenPercentage,
|
||||
scaling,
|
||||
settings.blur, settings.lockBlurPercentage,
|
||||
settings.vignette, settings.lockVignettePercentage,
|
||||
settings.grayscale, settings.lockGrayscalePercentage
|
||||
)?.let { lockImage ->
|
||||
setWallpaperSafely(lockImage, WallpaperManager.FLAG_LOCK, wallpaperManager)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
processBitmap(size.width, size.height, bitmap, darken, darkenPercent, scaling, blur, blurPercent, vignette, vignettePercent, grayscale, grayscalePercent)?.let { image ->
|
||||
setWallpaperSafely(image, WallpaperManager.FLAG_SYSTEM, wallpaperManager)
|
||||
}
|
||||
}
|
||||
context.triggerWallpaperTaskerEvent()
|
||||
return true
|
||||
@@ -595,102 +582,92 @@ class HomeWallpaperService: Service() {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the album by deleting invalid wallpapers and updating folder cover uri and wallpapers uri-
|
||||
*/
|
||||
private fun refreshAlbum(context: Context) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
Log.d("PaperizeWallpaperChanger", "Refreshing album")
|
||||
Log.d("PaperizeWallpaperChanger", "Refreshing albums")
|
||||
try {
|
||||
val albumWithWallpapers = albumRepository.getAlbumsWithWallpaperAndFolder().first()
|
||||
albumWithWallpapers.forEach { album ->
|
||||
// Remove invalid wallpapers
|
||||
val validWallpapers = async {
|
||||
album.wallpapers
|
||||
.asSequence()
|
||||
.filter { isValidUri(context, it.wallpaperUri) }
|
||||
.mapIndexed { index, wallpaper -> wallpaper.copy(order = index) }
|
||||
.toList()
|
||||
}
|
||||
val albumsToRefresh = albumRepository.getAlbumsWithWallpaperAndFolder().first()
|
||||
val settings = getWallpaperSettings()
|
||||
|
||||
// Remove invalid folders and inner wallpapers
|
||||
val validFolders = async {
|
||||
album.folders
|
||||
.asSequence()
|
||||
.filterNot { isDirectory(context, it.folderUri) }
|
||||
.map { folder ->
|
||||
async {
|
||||
val metadata = getFolderMetadata(folder.folderUri, context)
|
||||
if (metadata.lastModified != folder.dateModified) {
|
||||
val existingWallpapers = folder.wallpapers
|
||||
.asSequence()
|
||||
.filter { isValidUri(context, it.wallpaperUri) }
|
||||
.mapIndexed { index, wallpaper -> wallpaper.copy(order = index) }
|
||||
.toList()
|
||||
val newWallpapers =
|
||||
getWallpaperFromFolder(folder.folderUri, context)
|
||||
.asSequence()
|
||||
.filterNot { new -> existingWallpapers.any { it.wallpaperUri == new.wallpaperUri } }
|
||||
.mapIndexed { index, wallpaper ->
|
||||
wallpaper.copy(
|
||||
initialAlbumName = album.album.initialAlbumName,
|
||||
order = existingWallpapers.size + 1 + index,
|
||||
key = album.album.initialAlbumName.hashCode() +
|
||||
folder.folderUri.hashCode() +
|
||||
wallpaper.wallpaperUri.hashCode()
|
||||
)
|
||||
}.toList()
|
||||
val combinedWallpapers = existingWallpapers + newWallpapers
|
||||
folder.copy(
|
||||
coverUri = combinedWallpapers.firstOrNull()?.wallpaperUri ?: "",
|
||||
wallpapers = combinedWallpapers,
|
||||
dateModified = metadata.lastModified,
|
||||
folderName = metadata.filename
|
||||
)
|
||||
}
|
||||
else { folder }
|
||||
albumsToRefresh.forEach { albumWithDetails ->
|
||||
val validStandaloneWallpapers = albumWithDetails.wallpapers
|
||||
.filter { isValidUri(context, it.wallpaperUri) }
|
||||
|
||||
val updatedFolders = albumWithDetails.folders
|
||||
.mapNotNull { folder ->
|
||||
try {
|
||||
val metadata = getFolderMetadata(folder.folderUri, context)
|
||||
if (metadata.lastModified != folder.dateModified) {
|
||||
val wallpapersInDb = folder.wallpapers
|
||||
.filter { isValidUri(context, it.wallpaperUri) }
|
||||
.associateBy { it.wallpaperUri }
|
||||
|
||||
val wallpapersOnDisk = getWallpaperFromFolder(folder.folderUri, context)
|
||||
|
||||
val newWallpapers = wallpapersOnDisk
|
||||
.filterNot { wallpapersInDb.containsKey(it.wallpaperUri) }
|
||||
.mapIndexed { index, wallpaper ->
|
||||
wallpaper.copy(
|
||||
initialAlbumName = albumWithDetails.album.initialAlbumName,
|
||||
order = (wallpapersInDb.size) + 1 + index,
|
||||
key = albumWithDetails.album.initialAlbumName.hashCode() +
|
||||
folder.folderUri.hashCode() +
|
||||
wallpaper.wallpaperUri.hashCode()
|
||||
)
|
||||
}
|
||||
|
||||
val combinedWallpapers = wallpapersInDb.values.toList() + newWallpapers
|
||||
folder.copy(
|
||||
coverUri = combinedWallpapers.firstOrNull()?.wallpaperUri ?: "",
|
||||
wallpapers = combinedWallpapers.sortedBy { it.order },
|
||||
dateModified = metadata.lastModified,
|
||||
folderName = metadata.filename
|
||||
)
|
||||
} else {
|
||||
folder
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w("PaperizeWallpaperChanger", "Failed to process folder ${folder.folderUri}: ${e.message}")
|
||||
null
|
||||
}
|
||||
.toList()
|
||||
.awaitAll()
|
||||
}
|
||||
|
||||
val allValidWallpapers = (updatedFolders.flatMap { it.wallpapers } + validStandaloneWallpapers)
|
||||
.sortedBy { it.order }
|
||||
|
||||
if (allValidWallpapers.isEmpty()) {
|
||||
Log.d("PaperizeWallpaperChanger", "Album '${albumWithDetails.album.initialAlbumName}' is now empty. Deleting.")
|
||||
albumRepository.cascadeDeleteAlbum(albumWithDetails.album)
|
||||
return@forEach
|
||||
}
|
||||
|
||||
val folders = validFolders.await()
|
||||
val wallpapers = validWallpapers.await()
|
||||
if (folders.isNotEmpty() || wallpapers.isNotEmpty()) {
|
||||
val settings = getWallpaperSettings()
|
||||
val coverUri = findFirstValidUri(context, folders, wallpapers)
|
||||
val allValidWallpaperUri = (folders.flatMap { it.wallpapers } + wallpapers).sortedBy { it.order }.map{ it.wallpaperUri }.toSet()
|
||||
val validatedHomeQueue = album.album.homeWallpapersInQueue.filter { allValidWallpaperUri.contains(it) }
|
||||
val validatedLockQueue = album.album.lockWallpapersInQueue.filter { allValidWallpaperUri.contains(it) }
|
||||
val newUris = allValidWallpaperUri - (validatedHomeQueue + validatedLockQueue).toSet()
|
||||
val finalHomeQueue = if (settings.shuffle) {
|
||||
validatedHomeQueue + newUris.shuffled()
|
||||
} else {
|
||||
allValidWallpaperUri.filter { it in validatedHomeQueue || it in newUris }
|
||||
}
|
||||
val finalLockQueue = if (settings.shuffle) {
|
||||
validatedLockQueue + newUris.shuffled()
|
||||
} else {
|
||||
allValidWallpaperUri.filter { it in validatedLockQueue || it in newUris }
|
||||
}
|
||||
val allValidUris = allValidWallpapers.map { it.wallpaperUri }.toSet()
|
||||
|
||||
albumRepository.upsertAlbumWithWallpaperAndFolder(
|
||||
album.copy(
|
||||
album = album.album.copy(
|
||||
coverUri = coverUri,
|
||||
homeWallpapersInQueue = finalHomeQueue,
|
||||
lockWallpapersInQueue = finalLockQueue
|
||||
),
|
||||
wallpapers = wallpapers,
|
||||
folders = folders
|
||||
)
|
||||
fun rebuildQueue(currentQueue: List<String>, allWallpapers: List<String>, isShuffle: Boolean): List<String> {
|
||||
val validQueueItems = currentQueue.filter { allValidUris.contains(it) }
|
||||
val newItems = allWallpapers.filterNot { validQueueItems.contains(it) }
|
||||
return if (isShuffle) {
|
||||
validQueueItems + newItems.shuffled()
|
||||
} else {
|
||||
validQueueItems + newItems
|
||||
}
|
||||
}
|
||||
|
||||
val allValidUrisOrdered = allValidWallpapers.map { it.wallpaperUri }
|
||||
val finalHomeQueue = rebuildQueue(albumWithDetails.album.homeWallpapersInQueue, allValidUrisOrdered, settings.shuffle)
|
||||
val finalLockQueue = rebuildQueue(albumWithDetails.album.lockWallpapersInQueue, allValidUrisOrdered, settings.shuffle)
|
||||
|
||||
albumRepository.upsertAlbumWithWallpaperAndFolder(
|
||||
albumWithDetails.copy(
|
||||
album = albumWithDetails.album.copy(
|
||||
coverUri = findFirstValidUri(context, updatedFolders, validStandaloneWallpapers),
|
||||
homeWallpapersInQueue = finalHomeQueue,
|
||||
lockWallpapersInQueue = finalLockQueue
|
||||
),
|
||||
wallpapers = validStandaloneWallpapers,
|
||||
folders = updatedFolders
|
||||
)
|
||||
}
|
||||
else {
|
||||
Log.d("PaperizeWallpaperChanger", "No wallpaper found")
|
||||
albumRepository.cascadeDeleteAlbum(album.album)
|
||||
}
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("PaperizeWallpaperChanger", "Error refreshing album", e)
|
||||
@@ -714,4 +691,4 @@ class HomeWallpaperService: Service() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+64
-154
@@ -1,7 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.wallpaper_service
|
||||
|
||||
import android.Manifest
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
import android.app.WallpaperManager
|
||||
@@ -12,41 +11,27 @@ import android.net.Uri
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.os.IBinder
|
||||
import android.os.PowerManager
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresPermission
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.core.ScalingConstants
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
import com.anthonyla.paperize.core.Type
|
||||
import com.anthonyla.paperize.core.decompress
|
||||
import com.anthonyla.paperize.core.getDeviceScreenSize
|
||||
import com.anthonyla.paperize.core.isValidUri
|
||||
import com.anthonyla.paperize.core.processBitmap
|
||||
import com.anthonyla.paperize.core.retrieveBitmap
|
||||
import com.anthonyla.paperize.core.*
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.MainActivity
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
||||
import com.anthonyla.paperize.feature.wallpaper.tasker_shortcut.triggerWallpaperTaskerEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperBootAndChangeReceiver
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.IOException
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.FormatStyle
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Service to change lock screen
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
class LockWallpaperService: Service() {
|
||||
private val handleThread = HandlerThread("LockThread")
|
||||
@@ -57,20 +42,24 @@ class LockWallpaperService: Service() {
|
||||
private var homeInterval: Int = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
private var lockInterval: Int = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
private var type = Type.SINGLE.ordinal
|
||||
private var isForeground = false
|
||||
|
||||
enum class Actions {
|
||||
START,
|
||||
UPDATE
|
||||
}
|
||||
|
||||
override fun onBind(p0: Intent?): IBinder? {
|
||||
return null
|
||||
}
|
||||
override fun onBind(p0: Intent?): IBinder? = null
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
handleThread.start()
|
||||
workerHandler = Handler(handleThread.looper)
|
||||
if (!isForeground) {
|
||||
val notification = createInitialNotification()
|
||||
startForeground(1, notification)
|
||||
isForeground = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
@@ -83,9 +72,7 @@ class LockWallpaperService: Service() {
|
||||
type = intent.getIntExtra("type", Type.SINGLE.ordinal)
|
||||
workerTaskStart()
|
||||
}
|
||||
Actions.UPDATE.toString() -> {
|
||||
workerTaskUpdate()
|
||||
}
|
||||
Actions.UPDATE.toString() -> workerTaskUpdate()
|
||||
}
|
||||
}
|
||||
return START_NOT_STICKY
|
||||
@@ -98,63 +85,37 @@ class LockWallpaperService: Service() {
|
||||
}
|
||||
|
||||
private fun workerTaskStart() {
|
||||
workerHandler.post {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
changeWallpaper(this@LockWallpaperService)
|
||||
withContext(Dispatchers.Main) {
|
||||
stopSelf()
|
||||
}
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
changeWallpaper(this@LockWallpaperService)
|
||||
withContext(Dispatchers.Main) {
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun workerTaskUpdate() {
|
||||
workerHandler.post {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
updateCurrentWallpaper(this@LockWallpaperService)
|
||||
withContext(Dispatchers.Main) {
|
||||
stopSelf()
|
||||
}
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
updateCurrentWallpaper(this@LockWallpaperService)
|
||||
withContext(Dispatchers.Main) {
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a notification for the wallpaper service
|
||||
private fun createNotification(nextSetTime: LocalDateTime?): android.app.Notification? {
|
||||
nextSetTime?.let {
|
||||
val changeWallpaperIntent = Intent(this, WallpaperBootAndChangeReceiver::class.java)
|
||||
val pendingChangeWallpaperIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
changeWallpaperIntent,
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
val mainActivityIntent = Intent(this, MainActivity::class.java)
|
||||
val pendingMainActivityIntent = PendingIntent.getActivity(
|
||||
this,
|
||||
3,
|
||||
mainActivityIntent,
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val formattedNextSetTime = nextSetTime.format(formatter)
|
||||
|
||||
// Build the notification
|
||||
return NotificationCompat.Builder(this, "wallpaper_service_channel").apply {
|
||||
setContentTitle(getString(R.string.app_name))
|
||||
setContentText(getString(R.string.next_wallpaper_change, formattedNextSetTime))
|
||||
setSmallIcon(R.drawable.notification_icon)
|
||||
setContentIntent(pendingMainActivityIntent)
|
||||
addAction(R.drawable.notification_icon, getString(R.string.change_wallpaper), pendingChangeWallpaperIntent)
|
||||
priority = NotificationCompat.PRIORITY_DEFAULT
|
||||
setAutoCancel(true)
|
||||
}.build()
|
||||
}
|
||||
return null
|
||||
private fun createInitialNotification(): android.app.Notification {
|
||||
val mainActivityIntent = Intent(this, MainActivity::class.java)
|
||||
val pendingMainActivityIntent = PendingIntent.getActivity(
|
||||
this, 3, mainActivityIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
return NotificationCompat.Builder(this, "wallpaper_service_channel").apply {
|
||||
setContentTitle(getString(R.string.app_name))
|
||||
setContentText(getString(R.string.changing_wallpaper))
|
||||
setSmallIcon(R.drawable.notification_icon)
|
||||
setContentIntent(pendingMainActivityIntent)
|
||||
priority = NotificationCompat.PRIORITY_DEFAULT
|
||||
}.build()
|
||||
}
|
||||
|
||||
|
||||
private suspend fun getWallpaperSettings(): SettingsState.ServiceSettings {
|
||||
return SettingsState.ServiceSettings(
|
||||
enableChanger = settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: false,
|
||||
@@ -175,14 +136,12 @@ class LockWallpaperService: Service() {
|
||||
lockGrayscalePercentage = settingsDataStoreImpl.getInt(SettingsConstants.LOCK_GRAYSCALE_PERCENTAGE) ?: 0,
|
||||
lockAlbumName = settingsDataStoreImpl.getString(SettingsConstants.LOCK_ALBUM_NAME) ?: "",
|
||||
homeAlbumName = settingsDataStoreImpl.getString(SettingsConstants.HOME_ALBUM_NAME) ?: "",
|
||||
shuffle = settingsDataStoreImpl.getBoolean(SettingsConstants.SHUFFLE) ?: true
|
||||
shuffle = settingsDataStoreImpl.getBoolean(SettingsConstants.SHUFFLE) ?: true,
|
||||
skipLandscape = settingsDataStoreImpl.getBoolean(SettingsConstants.SKIP_LANDSCAPE) ?: false,
|
||||
skipNonInteractive = settingsDataStoreImpl.getBoolean(SettingsConstants.SKIP_NON_INTERACTIVE) ?: false
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the wallpaper to the next wallpaper in the queue of the selected album
|
||||
* If none left, reshuffle the wallpapers and pick the first one
|
||||
*/
|
||||
private suspend fun changeWallpaper(context: Context) {
|
||||
try {
|
||||
val selectedAlbum = albumRepository.getSelectedAlbums().first()
|
||||
@@ -195,6 +154,23 @@ class LockWallpaperService: Service() {
|
||||
onDestroy()
|
||||
return
|
||||
}
|
||||
|
||||
if (settings.skipLandscape && context.resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
|
||||
Log.d("PaperizeWallpaperChanger", "Skipping wallpaper change - device is in landscape mode")
|
||||
onDestroy()
|
||||
return
|
||||
}
|
||||
|
||||
if (settings.skipNonInteractive){
|
||||
val powerManager = context.getSystemService(POWER_SERVICE) as PowerManager
|
||||
if (!powerManager.isInteractive){
|
||||
Log.d(
|
||||
"PaperizeWallpaperChanger", "Skipping wallpaper change - device is in non-interactive state")
|
||||
onDestroy()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
val lockAlbum = selectedAlbum.find { it.album.initialAlbumName == settings.lockAlbumName }
|
||||
val homeAlbum = selectedAlbum.find { it.album.initialAlbumName == settings.homeAlbumName }
|
||||
if (lockAlbum == null || homeAlbum == null) {
|
||||
@@ -202,7 +178,6 @@ class LockWallpaperService: Service() {
|
||||
return
|
||||
}
|
||||
when {
|
||||
// Case: Set home and lock screen wallpapers using separate albums (home screen and lock screen album)
|
||||
settings.setHome && settings.setLock && scheduleSeparately -> {
|
||||
var wallpaper = lockAlbum.album.lockWallpapersInQueue.firstOrNull()
|
||||
if (wallpaper == null) {
|
||||
@@ -286,16 +261,8 @@ class LockWallpaperService: Service() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// // Refreshing home wallpaper to keep dynamic theming color based on home screen wallpaper
|
||||
// if (homeInterval != lockInterval) {
|
||||
// delay(15000)
|
||||
// val serviceIntent = Intent(context, HomeWallpaperService::class.java).apply { this.action = HomeWallpaperService.Actions.UPDATE.toString() }
|
||||
// context.startService(serviceIntent)
|
||||
// }
|
||||
}
|
||||
// Case: Set home and lock screen wallpapers using the same album (home screen album)
|
||||
settings.setHome && settings.setLock && !scheduleSeparately -> { /* handled by home wallpaper service */ return }
|
||||
// Case: Set lock screen wallpaper (lock screen album)
|
||||
settings.setLock -> {
|
||||
var wallpaper = lockAlbum.album.lockWallpapersInQueue.firstOrNull()
|
||||
if (wallpaper == null) {
|
||||
@@ -318,14 +285,14 @@ class LockWallpaperService: Service() {
|
||||
context = context,
|
||||
wallpaper = wallpaper.decompress("content://com.android.externalstorage.documents/").toUri(),
|
||||
darken = settings.darken,
|
||||
darkenPercent = settings.homeDarkenPercentage,
|
||||
darkenPercent = settings.lockDarkenPercentage,
|
||||
scaling = settings.scaling,
|
||||
blur = settings.blur,
|
||||
blurPercent = settings.homeBlurPercentage,
|
||||
blurPercent = settings.lockBlurPercentage,
|
||||
vignette = settings.vignette,
|
||||
vignettePercent = settings.homeVignettePercentage,
|
||||
vignettePercent = settings.lockVignettePercentage,
|
||||
grayscale = settings.grayscale,
|
||||
grayscalePercent = settings.homeGrayscalePercentage
|
||||
grayscalePercent = settings.lockGrayscalePercentage
|
||||
)
|
||||
}
|
||||
else {
|
||||
@@ -355,14 +322,14 @@ class LockWallpaperService: Service() {
|
||||
context = context,
|
||||
wallpaper = wallpaper.decompress("content://com.android.externalstorage.documents/").toUri(),
|
||||
darken = settings.darken,
|
||||
darkenPercent = settings.homeDarkenPercentage,
|
||||
darkenPercent = if (settings.setHome) settings.homeDarkenPercentage else settings.lockDarkenPercentage,
|
||||
scaling = settings.scaling,
|
||||
blur = settings.blur,
|
||||
blurPercent = settings.homeBlurPercentage,
|
||||
blurPercent = if (settings.setHome) settings.homeBlurPercentage else settings.lockBlurPercentage,
|
||||
vignette = settings.vignette,
|
||||
vignettePercent = settings.homeVignettePercentage,
|
||||
vignettePercent = if (settings.setHome) settings.homeVignettePercentage else settings.lockVignettePercentage,
|
||||
grayscale = settings.grayscale,
|
||||
grayscalePercent = settings.homeGrayscalePercentage
|
||||
grayscalePercent = if (settings.setHome) settings.homeGrayscalePercentage else settings.lockGrayscalePercentage
|
||||
)
|
||||
} else {
|
||||
val wallpaperToDelete = lockAlbum.wallpapers.find { it.wallpaperUri == wallpaper }
|
||||
@@ -383,64 +350,12 @@ class LockWallpaperService: Service() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run notification
|
||||
if (homeInterval != lockInterval && scheduleSeparately) {
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val homeNextSetTime = try {
|
||||
LocalDateTime.parse(settingsDataStoreImpl.getString(SettingsConstants.HOME_NEXT_SET_TIME))
|
||||
} catch (_: Exception) {
|
||||
LocalDateTime.now()
|
||||
}
|
||||
val currentTime = LocalDateTime.now()
|
||||
val lockNextSetTime = currentTime.plusMinutes(lockInterval.toLong())
|
||||
val nextSetTime = when {
|
||||
lockNextSetTime.isBefore(homeNextSetTime) && lockNextSetTime.isAfter(currentTime) -> lockNextSetTime
|
||||
homeNextSetTime.isAfter(currentTime) -> homeNextSetTime
|
||||
else -> lockNextSetTime
|
||||
}
|
||||
nextSetTime?.let {
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, currentTime.format(formatter))
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, it.format(formatter))
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LOCK_NEXT_SET_TIME, lockNextSetTime.toString())
|
||||
settingsDataStoreImpl.putString(SettingsConstants.HOME_NEXT_SET_TIME, homeNextSetTime.toString())
|
||||
}
|
||||
val notification = createNotification(nextSetTime)
|
||||
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
notification?.let { notificationManager.notify(1, it) }
|
||||
}
|
||||
else if (settings.setLock && !settings.setHome && !scheduleSeparately) {
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val homeNextSetTime = try {
|
||||
LocalDateTime.parse(settingsDataStoreImpl.getString(SettingsConstants.HOME_NEXT_SET_TIME))
|
||||
} catch (_: Exception) {
|
||||
LocalDateTime.now()
|
||||
}
|
||||
val currentTime = LocalDateTime.now()
|
||||
val lockNextSetTime = currentTime.plusMinutes(homeInterval.toLong())
|
||||
val nextSetTime = when {
|
||||
lockNextSetTime.isBefore(homeNextSetTime) && lockNextSetTime.isAfter(currentTime) -> lockNextSetTime
|
||||
homeNextSetTime.isAfter(currentTime) -> homeNextSetTime
|
||||
else -> lockNextSetTime
|
||||
}
|
||||
nextSetTime?.let {
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, currentTime.format(formatter))
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, it.format(formatter))
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LOCK_NEXT_SET_TIME, lockNextSetTime.toString())
|
||||
settingsDataStoreImpl.putString(SettingsConstants.HOME_NEXT_SET_TIME, homeNextSetTime.toString())
|
||||
}
|
||||
val notification = createNotification(nextSetTime)
|
||||
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
notification?.let { notificationManager.notify(1, it) }
|
||||
}
|
||||
Log.d("LockWallpaperService", "Wallpaper change task completed.")
|
||||
} catch (e: Exception) {
|
||||
Log.e("PaperizeWallpaperChanger", "Error in changing wallpaper", e)
|
||||
Log.e("PaperizeWallpaperChanger", "Error in changing wallpaper (Lock)", e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current wallpaper with current settings
|
||||
*/
|
||||
private suspend fun updateCurrentWallpaper(context: Context) {
|
||||
try {
|
||||
val selectedAlbum = albumRepository.getSelectedAlbums().first()
|
||||
@@ -459,23 +374,20 @@ class LockWallpaperService: Service() {
|
||||
context = context,
|
||||
wallpaper = currentLockWallpaper.decompress("content://com.android.externalstorage.documents/").toUri(),
|
||||
darken = settings.darken,
|
||||
darkenPercent = if (!settings.setHome) settings.homeDarkenPercentage else settings.lockDarkenPercentage,
|
||||
darkenPercent = if (settings.setHome) settings.homeDarkenPercentage else settings.lockDarkenPercentage,
|
||||
scaling = settings.scaling,
|
||||
blur = settings.blur,
|
||||
blurPercent = if (!settings.setHome) settings.homeBlurPercentage else settings.lockBlurPercentage,
|
||||
blurPercent = if (settings.setHome) settings.homeBlurPercentage else settings.lockBlurPercentage,
|
||||
vignette = settings.vignette,
|
||||
vignettePercent = if (!settings.setHome) settings.homeVignettePercentage else settings.lockVignettePercentage,
|
||||
vignettePercent = if (settings.setHome) settings.homeVignettePercentage else settings.lockVignettePercentage,
|
||||
grayscale = settings.grayscale,
|
||||
grayscalePercent = if (!settings.setHome) settings.homeGrayscalePercentage else settings.lockGrayscalePercentage
|
||||
grayscalePercent = if (settings.setHome) settings.homeGrayscalePercentage else settings.lockGrayscalePercentage
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e("PaperizeWallpaperChanger", "Error in updating", e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the wallpaper to the given uri
|
||||
*/
|
||||
private fun setWallpaper(
|
||||
context: Context,
|
||||
wallpaper: Uri?,
|
||||
@@ -499,9 +411,7 @@ class LockWallpaperService: Service() {
|
||||
else if (wallpaperManager.isSetWallpaperAllowed) {
|
||||
processBitmap(size.width, size.height, bitmap, darken, darkenPercent, scaling, blur, blurPercent, vignette, vignettePercent, grayscale, grayscalePercent)?.let { image ->
|
||||
setWallpaperSafely(image, WallpaperManager.FLAG_LOCK, wallpaperManager)
|
||||
image.recycle()
|
||||
}
|
||||
bitmap.recycle()
|
||||
context.triggerWallpaperTaskerEvent()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -148,6 +148,8 @@
|
||||
<string name="show_interval_sliders">Show interval sliders</string>
|
||||
<string name="interval_text">Time Interval</string>
|
||||
<string name="change_blur">Blur Effect</string>
|
||||
<string name="skip_landscape_mode">Skip in landscape mode</string>
|
||||
<string name="skip_non_interactive_state">Skip in non-interactive state</string>
|
||||
<string name="paperize_is_running">Paperize is running</string>
|
||||
<string name="next_wallpaper_change">Next wallpaper change: %1$s</string>
|
||||
<string name="delay_notice">Delay Notice</string>
|
||||
@@ -190,4 +192,7 @@
|
||||
<string name="darken_the_edges_of_the_image">Darken the edges of the image</string>
|
||||
<string name="make_the_colors_grayscale">Make the colors grayscale</string>
|
||||
<string name="shuffle_the_wallpapers">Shuffle the wallpapers</string>
|
||||
<string name="prevent_changing_during_landscape_mode">Prevent changing during landscape mode</string>
|
||||
<string name="prevent_changing_during_non_interactive_state">Prevent changing during non-interactive\nstate (e.g. Screen is off)</string>
|
||||
<string name="changing_wallpaper">Changing wallpaper…</string>
|
||||
</resources>
|
||||
+31
-29
@@ -1,57 +1,59 @@
|
||||
[versions]
|
||||
androidGradlePlugin = "8.10.1"
|
||||
kotlin = "2.1.21"
|
||||
hilt = "2.56.2"
|
||||
ksp = "2.1.21-2.0.2"
|
||||
androidGradlePlugin = "8.12.1"
|
||||
kotlin = "2.2.10"
|
||||
hilt = "2.57.1"
|
||||
ksp = "2.2.10-2.0.2"
|
||||
renderscriptToolkit = "1.0.0"
|
||||
|
||||
[libraries]
|
||||
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version = "0.37.3" }
|
||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.10.1" }
|
||||
androidx-animation = { module = "androidx.compose.animation:animation", version = "1.8.3" }
|
||||
androidx-compose-bom = { module = "androidx.compose:compose-bom", version = "2025.06.01" }
|
||||
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.16.0" }
|
||||
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version = "1.2.0-beta02" }
|
||||
androidx-animation = { module = "androidx.compose.animation:animation", version = "1.9.0" }
|
||||
androidx-compose-bom = { module = "androidx.compose:compose-bom", version = "2025.08.00" }
|
||||
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.17.0" }
|
||||
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version = "1.2.0-rc01" }
|
||||
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version = "1.1.7" }
|
||||
androidx-datastore = { module = "androidx.datastore:datastore", version = "1.1.7" }
|
||||
androidx-documentfile = { module = "androidx.documentfile:documentfile", version = "1.1.0" }
|
||||
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version = "3.6.1" }
|
||||
androidx-foundation = { module = "androidx.compose.foundation:foundation", version = "1.8.3" }
|
||||
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version = "3.7.0" }
|
||||
androidx-foundation = { module = "androidx.compose.foundation:foundation", version = "1.9.0" }
|
||||
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version = "1.2.0" }
|
||||
androidx-hilt-work = { module = "androidx.hilt:hilt-work", version = "1.2.0" }
|
||||
androidx-junit = { module = "androidx.test.ext:junit", version = "1.2.1" }
|
||||
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version = "2.9.1" }
|
||||
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version = "2.9.1" }
|
||||
androidx-material = { module = "androidx.compose.material:material", version = "1.8.3" }
|
||||
androidx-junit = { module = "androidx.test.ext:junit", version = "1.3.0" }
|
||||
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version = "2.9.2" }
|
||||
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version = "2.9.2" }
|
||||
androidx-material = { module = "androidx.compose.material:material", version = "1.9.0" }
|
||||
androidx-material-icons-extended = { module = "androidx.compose.material:material-icons-extended", version = "1.7.8" }
|
||||
androidx-material3 = { module = "androidx.compose.material3:material3", version = "1.4.0-alpha16" }
|
||||
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version = "2.9.0" }
|
||||
androidx-material3 = { module = "androidx.compose.material3:material3", version = "1.4.0-beta02" }
|
||||
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version = "2.9.3" }
|
||||
androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version = "1.4.1" }
|
||||
androidx-room-ktx = { module = "androidx.room:room-ktx", version = "2.7.2" }
|
||||
androidx-room-compiler = { module = "androidx.room:room-compiler", version = "2.7.2" }
|
||||
androidx-room-runtime = { module = "androidx.room:room-runtime", version = "2.7.2" }
|
||||
androidx-ui = { module = "androidx.compose.ui:ui", version = "1.8.3" }
|
||||
androidx-ui-graphics = { module = "androidx.compose.ui:ui-graphics", version = "1.8.3" }
|
||||
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version = "1.8.3" }
|
||||
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version = "1.8.3" }
|
||||
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version = "1.8.3" }
|
||||
androidx-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version = "1.8.3" }
|
||||
androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version = "2.10.2" }
|
||||
androidx-ui = { module = "androidx.compose.ui:ui", version = "1.9.0" }
|
||||
androidx-ui-graphics = { module = "androidx.compose.ui:ui-graphics", version = "1.9.0" }
|
||||
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version = "1.9.0" }
|
||||
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version = "1.9.0" }
|
||||
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version = "1.9.0" }
|
||||
androidx-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version = "1.9.0" }
|
||||
androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version = "2.10.3" }
|
||||
dfc = { module = "com.lazygeniouz:dfc", version = "1.2" }
|
||||
gson = { module = "com.google.code.gson:gson", version = "2.13.1" }
|
||||
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version = "2.56.2" }
|
||||
hilt-android = { module = "com.google.dagger:hilt-android", version = "2.56.2" }
|
||||
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
|
||||
hilt-android-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
|
||||
junit = { module = "junit:junit", version = "4.13.2" }
|
||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.8.1" }
|
||||
landscapist-glide = { module = "com.github.skydoves:landscapist-glide", version = "2.5.0" }
|
||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.9.0" }
|
||||
landscapist-glide = { module = "com.github.skydoves:landscapist-glide", version = "2.5.2" }
|
||||
lazycolumnscrollbar = { module = "com.github.nanihadesuka:LazyColumnScrollbar", version = "2.2.0" }
|
||||
lottie-compose = { module = "com.airbnb.android:lottie-compose", version = "6.6.7" }
|
||||
taskerpluginlibrary = { module = "com.joaomgcd:taskerpluginlibrary", version = "0.4.10" }
|
||||
toolbar-compose = { module = "me.onebone:toolbar-compose", version = "2.3.5" }
|
||||
zoomable = { module = "net.engawapg.lib:zoomable", version = "2.8.0" }
|
||||
reorderable = { group = "sh.calvin.reorderable", name = "reorderable", version = "2.5.1" }
|
||||
zoomable = { module = "net.engawapg.lib:zoomable", version = "2.8.1" }
|
||||
reorderable = { group = "sh.calvin.reorderable", name = "reorderable", version = "3.0.0" }
|
||||
androidx-glance-appwidget = { group = "androidx.glance", name = "glance-appwidget", version = "1.1.1" }
|
||||
androidx-glance-material3 = { group = "androidx.glance", name = "glance-material3", version = "1.1.1" }
|
||||
androidx-glance-material = { group = "androidx.glance", name = "glance-material", version = "1.1.1" }
|
||||
renderscript-toolkit = { group = "io.github.anthonyy232", name = "renderscript-toolkit", version.ref = "renderscriptToolkit" }
|
||||
|
||||
[plugins]
|
||||
androidApplication = { id = "com.android.application", version.ref = "androidGradlePlugin" }
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=7197a12f450794931532469d4ff21a59ea2c1cd59a3ec3f89c035c3c420a6999
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
|
||||
distributionSha256Sum=8fad3d78296ca518113f3d29016617c7f9367dc005f932bd9d93bf45ba46072b
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
Reference in new issue
Block a user