Added vignette effect
This commit is contained in:
1 parent
9563bf2057
commit
0d8fee5929
15 files changed
+526
-33
No files matched your search
@@ -32,6 +32,9 @@ object SettingsConstants {
|
||||
const val BLUR = "blur"
|
||||
const val HOME_BLUR_PERCENTAGE = "home_blur_percentage"
|
||||
const val LOCK_BLUR_PERCENTAGE = "lock_blur_percentage"
|
||||
const val VIGNETTE = "vignette"
|
||||
const val HOME_VIGNETTE_PERCENTAGE = "home_vignette_percentage"
|
||||
const val LOCK_VIGNETTE_PERCENTAGE = "lock_vignette_percentage"
|
||||
const val HOME_NEXT_SET_TIME = "next_set_time_1"
|
||||
const val LOCK_NEXT_SET_TIME = "next_set_time_2"
|
||||
const val NEXT_HOME_WALLPAPER = "next_home_wallpaper"
|
||||
|
||||
@@ -8,6 +8,10 @@ import android.graphics.ColorMatrix
|
||||
import android.graphics.ColorMatrixColorFilter
|
||||
import android.graphics.ImageDecoder
|
||||
import android.graphics.Paint
|
||||
import android.graphics.RadialGradient
|
||||
import android.graphics.Rect
|
||||
import android.graphics.RectF
|
||||
import android.graphics.Shader
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.util.DisplayMetrics
|
||||
@@ -22,6 +26,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import com.google.android.renderscript.Toolkit
|
||||
import com.lazygeniouz.dfc.file.DocumentFileCompat
|
||||
|
||||
|
||||
enum class Type { HOME, LOCK, SINGLE, REFRESH }
|
||||
|
||||
/**
|
||||
@@ -210,6 +215,47 @@ fun blurBitmap(source: Bitmap, percent: Int): Bitmap {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a vignette effect to the bitmap
|
||||
*/
|
||||
fun vignetteBitmap(source: Bitmap, percent: Int): Bitmap {
|
||||
return try {
|
||||
val image = Bitmap.createBitmap(source.width, source.height, Bitmap.Config.ARGB_8888)
|
||||
val canvas = Canvas(image)
|
||||
canvas.drawBitmap(source, 0f, 0f, Paint())
|
||||
val rad: Int = if (source.width < source.height) {
|
||||
val o = (source.height * 2) / 100
|
||||
source.height - o * percent / 3
|
||||
} else {
|
||||
val o = (source.width * 2) / 100
|
||||
source.width - o * percent / 3
|
||||
}
|
||||
val rect = Rect(0, 0, source.width, source.height)
|
||||
val rectF = RectF(rect)
|
||||
val colors = intArrayOf(0, 0, Color.BLACK)
|
||||
val pos = floatArrayOf(0.0f, 0.1f, 1.0f)
|
||||
val linGradLR: Shader = RadialGradient(
|
||||
rect.centerX().toFloat(),
|
||||
rect.centerY().toFloat(),
|
||||
rad.toFloat(),
|
||||
colors,
|
||||
pos,
|
||||
Shader.TileMode.CLAMP
|
||||
)
|
||||
val paint = Paint().apply {
|
||||
shader = linGradLR
|
||||
isAntiAlias = true
|
||||
isDither = true
|
||||
alpha = 128
|
||||
}
|
||||
canvas.drawRect(rectF, paint)
|
||||
image
|
||||
} catch (e: Exception) {
|
||||
Log.e("WallpaperUtil", "Error applying vignette effect: $e")
|
||||
source
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve wallpaper URIs from a folder directory URI
|
||||
*/
|
||||
@@ -347,7 +393,9 @@ fun processBitmap(
|
||||
darkenPercent: Int,
|
||||
scaling: ScalingConstants,
|
||||
blur: Boolean,
|
||||
blurPercent: Int
|
||||
blurPercent: Int,
|
||||
vignette: Boolean,
|
||||
vignettePercent: Int
|
||||
): Bitmap? {
|
||||
try {
|
||||
var processedBitmap = source
|
||||
@@ -368,6 +416,12 @@ fun processBitmap(
|
||||
if (blur && blurPercent > 0) {
|
||||
processedBitmap = blurBitmap(processedBitmap, blurPercent)
|
||||
}
|
||||
|
||||
// Apply vignette effect
|
||||
if (vignette && vignettePercent > 0) {
|
||||
processedBitmap = vignetteBitmap(processedBitmap, vignettePercent)
|
||||
}
|
||||
|
||||
return processedBitmap
|
||||
} catch (e: Exception) {
|
||||
Log.e("PaperizeWallpaperChanger", "Error darkening bitmap", e)
|
||||
|
||||
+25
-2
@@ -225,6 +225,9 @@ fun PaperizeApp(
|
||||
lockBlurPercentage = settingsState.value.lockBlurPercentage,
|
||||
currentHomeWallpaper = settingsState.value.currentHomeWallpaper,
|
||||
currentLockWallpaper = settingsState.value.currentLockWallpaper,
|
||||
vignette = settingsState.value.vignette,
|
||||
homeVignettePercentage = settingsState.value.homeVignettePercentage,
|
||||
lockVignettePercentage = settingsState.value.lockVignettePercentage,
|
||||
onSettingsClick = { navController.navigate(Settings) },
|
||||
navigateToAddWallpaperScreen = {
|
||||
navController.navigate(AddEdit(it))
|
||||
@@ -479,7 +482,7 @@ fun PaperizeApp(
|
||||
},
|
||||
onDarkCheck = {
|
||||
settingsViewModel.onEvent(SettingsEvent.SetDarken(it))
|
||||
if (settingsState.value.enableChanger && (settingsState.value.darken && settingsState.value.homeDarkenPercentage < 100)) {
|
||||
if (settingsState.value.enableChanger && (it && settingsState.value.homeDarkenPercentage < 100)) {
|
||||
job?.cancel()
|
||||
job = scope.launch {
|
||||
delay(1000)
|
||||
@@ -668,7 +671,7 @@ fun PaperizeApp(
|
||||
},
|
||||
onBlurChange = {
|
||||
settingsViewModel.onEvent(SettingsEvent.SetBlur(it))
|
||||
if (settingsState.value.enableChanger && settingsState.value.blur) {
|
||||
if (settingsState.value.enableChanger && it) {
|
||||
job?.cancel()
|
||||
job = scope.launch {
|
||||
delay(1000)
|
||||
@@ -686,6 +689,26 @@ fun PaperizeApp(
|
||||
}
|
||||
}
|
||||
},
|
||||
onVignetteChange = {
|
||||
settingsViewModel.onEvent(SettingsEvent.SetVignette(it))
|
||||
if (settingsState.value.enableChanger && it) {
|
||||
job?.cancel()
|
||||
job = scope.launch {
|
||||
delay(1000)
|
||||
scheduler.updateWallpaper(settingsState.value.scheduleSeparately, settingsState.value.setHomeWallpaper, settingsState.value.setLockWallpaper)
|
||||
}
|
||||
}
|
||||
},
|
||||
onVignettePercentageChange = { home, lock ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetVignettePercentage(home, lock))
|
||||
if (settingsState.value.enableChanger && settingsState.value.vignette) {
|
||||
job?.cancel()
|
||||
job = scope.launch {
|
||||
delay(3000)
|
||||
scheduler.updateWallpaper(settingsState.value.scheduleSeparately, settingsState.value.setHomeWallpaper, settingsState.value.setLockWallpaper)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
// Navigate to the add album screen to create a new album and add wallpapers to it
|
||||
|
||||
+11
-1
@@ -70,6 +70,11 @@ fun HomeScreen(
|
||||
currentLockWallpaper: String?,
|
||||
homeSelectedAlbum: SelectedAlbum?,
|
||||
lockSelectedAlbum: SelectedAlbum?,
|
||||
homeVignettePercentage: Int,
|
||||
lockVignettePercentage: Int,
|
||||
onVignettePercentageChange: (Int, Int) -> Unit,
|
||||
onVignetteChange: (Boolean) -> Unit,
|
||||
vignette: Boolean
|
||||
) {
|
||||
val tabItems = getTabItems()
|
||||
val pagerState = rememberPagerState(0) { tabItems.size }
|
||||
@@ -168,7 +173,12 @@ fun HomeScreen(
|
||||
homeBlurPercentage = homeBlurPercentage,
|
||||
lockBlurPercentage = lockBlurPercentage,
|
||||
currentHomeWallpaper = currentHomeWallpaper,
|
||||
currentLockWallpaper = currentLockWallpaper
|
||||
currentLockWallpaper = currentLockWallpaper,
|
||||
homeVignettePercentage = homeVignettePercentage,
|
||||
lockVignettePercentage = lockVignettePercentage,
|
||||
onVignettePercentageChange = onVignettePercentageChange,
|
||||
onVignetteChange = onVignetteChange,
|
||||
vignette = vignette
|
||||
)
|
||||
else -> LibraryScreen(
|
||||
albums = albums,
|
||||
|
||||
+2
@@ -14,6 +14,7 @@ sealed class SettingsEvent {
|
||||
data class SetAnimate(val animate: Boolean): SettingsEvent()
|
||||
data class SetDarken(val darken: Boolean): SettingsEvent()
|
||||
data class SetBlur(val blur: Boolean): SettingsEvent()
|
||||
data class SetVignette(val vignette: Boolean): SettingsEvent()
|
||||
data class SetLock(val lock: Boolean): SettingsEvent()
|
||||
data class SetHome(val home: Boolean): SettingsEvent()
|
||||
data class SetCurrentHomeWallpaper(val currentHomeWallpaper: String?): SettingsEvent()
|
||||
@@ -27,6 +28,7 @@ sealed class SettingsEvent {
|
||||
data class SetLockWallpaperInterval(val interval: Int): SettingsEvent()
|
||||
data class SetDarkenPercentage(val homeDarkenPercentage: Int?, val lockDarkenPercentage: Int?): SettingsEvent()
|
||||
data class SetBlurPercentage(val homeBlurPercentage: Int?, val lockBlurPercentage: Int?): SettingsEvent()
|
||||
data class SetVignettePercentage(val homeVignettePercentage: Int?, val lockVignettePercentage: Int?): SettingsEvent()
|
||||
data class SetChangerToggle(val toggle: Boolean): SettingsEvent()
|
||||
data class SetWallpaperScaling(val scaling: ScalingConstants): SettingsEvent()
|
||||
data class SetNextHomeWallpaper(val nextHomeWallpaper: String?): SettingsEvent()
|
||||
|
||||
+3
@@ -28,6 +28,9 @@ data class SettingsState(
|
||||
val blur: Boolean = false,
|
||||
val homeBlurPercentage: Int = 0,
|
||||
val lockBlurPercentage: Int = 0,
|
||||
val vignette: Boolean = false,
|
||||
val homeVignettePercentage: Int = 0,
|
||||
val lockVignettePercentage: Int = 0,
|
||||
val wallpaperScaling: ScalingConstants = ScalingConstants.FILL,
|
||||
val nextHomeWallpaper: String? = null,
|
||||
val nextLockWallpaper: String? = null
|
||||
|
||||
+50
-3
@@ -58,6 +58,9 @@ class SettingsViewModel @Inject constructor (
|
||||
val blur = async { settingsDataStoreImpl.getBoolean(SettingsConstants.BLUR) ?: false }
|
||||
val homeBlurPercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.HOME_BLUR_PERCENTAGE) ?: 0 }
|
||||
val lockBlurPercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.LOCK_BLUR_PERCENTAGE) ?: 0 }
|
||||
val vignette = async { settingsDataStoreImpl.getBoolean(SettingsConstants.VIGNETTE) ?: false }
|
||||
val homeVignettePercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.HOME_VIGNETTE_PERCENTAGE) ?: 0 }
|
||||
val lockVignettePercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.LOCK_VIGNETTE_PERCENTAGE) ?: 0 }
|
||||
val nextHomeWallpaper = async { settingsDataStoreImpl.getString(SettingsConstants.HOME_NEXT_SET_TIME) }
|
||||
val nextLockWallpaper = async { settingsDataStoreImpl.getString(SettingsConstants.LOCK_NEXT_SET_TIME) }
|
||||
|
||||
@@ -88,7 +91,10 @@ class SettingsViewModel @Inject constructor (
|
||||
homeBlurPercentage = homeBlurPercentage.await(),
|
||||
lockBlurPercentage = lockBlurPercentage.await(),
|
||||
nextHomeWallpaper = nextHomeWallpaper.await(),
|
||||
nextLockWallpaper = nextLockWallpaper.await()
|
||||
nextLockWallpaper = nextLockWallpaper.await(),
|
||||
vignette = vignette.await(),
|
||||
homeVignettePercentage = homeVignettePercentage.await(),
|
||||
lockVignettePercentage = lockVignettePercentage.await()
|
||||
)
|
||||
}
|
||||
setKeepOnScreenCondition = false
|
||||
@@ -147,6 +153,10 @@ class SettingsViewModel @Inject constructor (
|
||||
val lockBlurPercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.LOCK_BLUR_PERCENTAGE) ?: 0 }
|
||||
val nextHomeWallpaper = async { settingsDataStoreImpl.getString(SettingsConstants.HOME_NEXT_SET_TIME) }
|
||||
val nextLockWallpaper = async { settingsDataStoreImpl.getString(SettingsConstants.LOCK_NEXT_SET_TIME) }
|
||||
val vignette = async { settingsDataStoreImpl.getBoolean(SettingsConstants.VIGNETTE) ?: false }
|
||||
val homeVignettePercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.HOME_VIGNETTE_PERCENTAGE) ?: 0 }
|
||||
val lockVignettePercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.LOCK_VIGNETTE_PERCENTAGE) ?: 0 }
|
||||
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
@@ -173,7 +183,10 @@ class SettingsViewModel @Inject constructor (
|
||||
homeBlurPercentage = homeBlurPercentage.await(),
|
||||
lockBlurPercentage = lockBlurPercentage.await(),
|
||||
nextHomeWallpaper = nextHomeWallpaper.await(),
|
||||
nextLockWallpaper = nextLockWallpaper.await()
|
||||
nextLockWallpaper = nextLockWallpaper.await(),
|
||||
vignette = vignette.await(),
|
||||
homeVignettePercentage = homeVignettePercentage.await(),
|
||||
lockVignettePercentage = lockVignettePercentage.await()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -426,6 +439,34 @@ class SettingsViewModel @Inject constructor (
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetVignette -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.VIGNETTE, event.vignette)
|
||||
_state.update {
|
||||
it.copy(
|
||||
vignette = event.vignette
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetVignettePercentage -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
if (event.lockVignettePercentage != null) {
|
||||
settingsDataStoreImpl.putInt(SettingsConstants.LOCK_VIGNETTE_PERCENTAGE, event.lockVignettePercentage)
|
||||
}
|
||||
if (event.homeVignettePercentage != null) {
|
||||
settingsDataStoreImpl.putInt(SettingsConstants.HOME_VIGNETTE_PERCENTAGE, event.homeVignettePercentage)
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
homeVignettePercentage = event.homeVignettePercentage ?: it.homeVignettePercentage,
|
||||
lockVignettePercentage = event.lockVignettePercentage ?: it.lockVignettePercentage
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetCurrentHomeWallpaper -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
if (event.currentHomeWallpaper != null) {
|
||||
@@ -659,6 +700,9 @@ class SettingsViewModel @Inject constructor (
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.LOCK_NEXT_SET_TIME)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.NEXT_HOME_WALLPAPER)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.NEXT_LOCK_WALLPAPER)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.VIGNETTE)
|
||||
settingsDataStoreImpl.deleteInt(SettingsConstants.HOME_VIGNETTE_PERCENTAGE)
|
||||
settingsDataStoreImpl.deleteInt(SettingsConstants.LOCK_VIGNETTE_PERCENTAGE)
|
||||
|
||||
_state.update {
|
||||
it.copy(
|
||||
@@ -687,7 +731,10 @@ class SettingsViewModel @Inject constructor (
|
||||
scheduleSeparately = false,
|
||||
blur = false,
|
||||
nextHomeWallpaper = null,
|
||||
nextLockWallpaper = null
|
||||
nextLockWallpaper = null,
|
||||
vignette = false,
|
||||
homeVignettePercentage = 0,
|
||||
lockVignettePercentage = 0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+19
-1
@@ -40,6 +40,7 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.co
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.DarkenSwitchAndSlider
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.IndividualSchedulingAndToggleRow
|
||||
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
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -79,7 +80,12 @@ fun WallpaperScreen(
|
||||
onBlurPercentageChange: (Int, Int) -> Unit,
|
||||
onBlurChange: (Boolean) -> Unit,
|
||||
homeBlurPercentage: Int,
|
||||
lockBlurPercentage: Int
|
||||
lockBlurPercentage: Int,
|
||||
homeVignettePercentage: Int,
|
||||
lockVignettePercentage: Int,
|
||||
onVignettePercentageChange: (Int, Int) -> Unit,
|
||||
onVignetteChange: (Boolean) -> Unit,
|
||||
vignette: Boolean
|
||||
) {
|
||||
val shouldShowScreen = homeEnabled || lockEnabled
|
||||
val shouldShowSettings = shouldShowScreen && homeSelectedAlbum != null && lockSelectedAlbum != null
|
||||
@@ -200,6 +206,9 @@ fun WallpaperScreen(
|
||||
blur = blur,
|
||||
homeBlurPercentage = homeBlurPercentage,
|
||||
lockBlurPercentage = lockBlurPercentage,
|
||||
vignette = vignette,
|
||||
homeVignettePercentage = homeVignettePercentage,
|
||||
lockVignettePercentage = lockVignettePercentage
|
||||
)
|
||||
CurrentAndNextChange(lastSetTime, nextSetTime)
|
||||
TimeSliders(
|
||||
@@ -238,6 +247,15 @@ fun WallpaperScreen(
|
||||
animate = animate,
|
||||
bothEnabled = homeEnabled && lockEnabled
|
||||
)
|
||||
VignetteSwitchAndSlider(
|
||||
onVignettePercentageChange = onVignettePercentageChange,
|
||||
onVignetteChange = onVignetteChange,
|
||||
vignette = vignette,
|
||||
homeVignettePercentage = homeVignettePercentage,
|
||||
lockVignettePercentage = lockVignettePercentage,
|
||||
animate = animate,
|
||||
bothEnabled = homeEnabled && lockEnabled
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
-6
@@ -23,6 +23,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.times
|
||||
import com.anthonyla.paperize.core.ScalingConstants
|
||||
import com.anthonyla.paperize.core.isValidUri
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.skydoves.landscapist.ImageOptions
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
||||
@@ -32,18 +33,19 @@ import com.skydoves.landscapist.glide.GlideImage
|
||||
@Composable
|
||||
fun PreviewItem(
|
||||
wallpaperUri: String,
|
||||
darken: Boolean = false,
|
||||
darken: Boolean,
|
||||
darkenPercentage: Int,
|
||||
blur: Boolean = false,
|
||||
blur: Boolean,
|
||||
blurPercentage: Int,
|
||||
scaling: ScalingConstants
|
||||
scaling: ScalingConstants,
|
||||
vignette: Boolean,
|
||||
vignettePercentage: Int
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val showUri by remember { mutableStateOf(isValidUri(context, wallpaperUri)) }
|
||||
val configuration = LocalConfiguration.current
|
||||
val screenWidth = configuration.screenWidthDp.dp
|
||||
val screenHeight = configuration.screenHeightDp.dp
|
||||
|
||||
if (showUri) {
|
||||
GlideImage(
|
||||
imageModel = { wallpaperUri },
|
||||
@@ -61,7 +63,15 @@ fun PreviewItem(
|
||||
BlendMode.Darken
|
||||
)
|
||||
} else { null },
|
||||
tag = vignette.toString() + vignettePercentage.toString(),
|
||||
),
|
||||
requestOptions = {
|
||||
if (vignette && vignettePercentage > 0) {
|
||||
RequestOptions.bitmapTransform(VignetteBitmapTransformation(vignettePercentage))
|
||||
} else {
|
||||
RequestOptions()
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.size(screenWidth * 0.35f, screenHeight * 0.35f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
@@ -69,8 +79,13 @@ fun PreviewItem(
|
||||
.background(Color.Black)
|
||||
.blur(
|
||||
if (blur && blurPercentage > 0) {
|
||||
blurPercentage.toFloat().div(100f) * 1.5.dp
|
||||
} else { 0.dp })
|
||||
blurPercentage
|
||||
.toFloat()
|
||||
.div(100f) * 1.5.dp
|
||||
} else {
|
||||
0.dp
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import com.anthonyla.paperize.core.vignetteBitmap
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||
import com.bumptech.glide.util.Util
|
||||
import java.security.MessageDigest
|
||||
|
||||
/**
|
||||
* A BitmapTransformation that applies a vignette effect to a bitmap to be used with Glide
|
||||
*/
|
||||
class VignetteBitmapTransformation(private val percent: Int): BitmapTransformation() {
|
||||
|
||||
override fun transform(
|
||||
pool: BitmapPool,
|
||||
toTransform: Bitmap,
|
||||
outWidth: Int,
|
||||
outHeight: Int
|
||||
): Bitmap {
|
||||
return vignetteBitmap(toTransform, percent)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other is VignetteBitmapTransformation && other.percent == percent
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return Util.hashCode(percent)
|
||||
}
|
||||
|
||||
override fun updateDiskCacheKey(messageDigest: MessageDigest) {
|
||||
messageDigest.update((ID + percent).toByteArray(CHARSET))
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ID = "com.bumptech.glide.transformations.VignettedBitmapTransformation"
|
||||
}
|
||||
}
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import android.view.HapticFeedbackConstants
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.animation.core.LinearOutSlowInEasing
|
||||
import androidx.compose.animation.core.Spring
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.expandVertically
|
||||
import androidx.compose.animation.fadeOut
|
||||
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.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* Composable that displays a switch and slider for the vignette effect
|
||||
*/
|
||||
@Composable
|
||||
fun VignetteSwitchAndSlider(
|
||||
onVignettePercentageChange: (Int, Int) -> Unit,
|
||||
onVignetteChange: (Boolean) -> Unit,
|
||||
vignette: Boolean,
|
||||
bothEnabled: Boolean,
|
||||
homeVignettePercentage: Int,
|
||||
lockVignettePercentage: Int,
|
||||
animate: Boolean
|
||||
) {
|
||||
val view = LocalView.current
|
||||
val scope = rememberCoroutineScope()
|
||||
var job by remember { mutableStateOf<Job?>(null) }
|
||||
var homePercentage by rememberSaveable { mutableFloatStateOf(homeVignettePercentage.toFloat()) }
|
||||
var lockPercentage by rememberSaveable { mutableFloatStateOf(lockVignettePercentage.toFloat()) }
|
||||
|
||||
Surface(
|
||||
tonalElevation = 10.dp,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
|
||||
) {
|
||||
val columnModifier = if (animate) {
|
||||
Modifier.animateContentSize(animationSpec = tween(durationMillis = 300, easing = LinearOutSlowInEasing))
|
||||
} else { Modifier }
|
||||
Column (
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
modifier = columnModifier
|
||||
) {
|
||||
Row (horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
text = stringResource(R.string.change_vignette),
|
||||
modifier = Modifier.padding(16.dp),
|
||||
fontWeight = FontWeight.W500
|
||||
)
|
||||
Switch(
|
||||
checked = vignette,
|
||||
onCheckedChange = onVignetteChange
|
||||
)
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = vignette,
|
||||
enter = expandVertically(animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow)),
|
||||
exit = fadeOut(
|
||||
animationSpec = tween(
|
||||
durationMillis = 300,
|
||||
easing = LinearOutSlowInEasing
|
||||
)
|
||||
)
|
||||
) {
|
||||
Column {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
if (bothEnabled) {
|
||||
Text(
|
||||
text = stringResource(R.string.home_screen) + " | " + stringResource(R.string.percentage, homePercentage.roundToInt()),
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp)),
|
||||
fontWeight = FontWeight.W400
|
||||
)
|
||||
}
|
||||
else {
|
||||
Text(
|
||||
text = stringResource(R.string.percentage, homePercentage.roundToInt()),
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp)),
|
||||
fontWeight = FontWeight.W400
|
||||
)
|
||||
}
|
||||
Slider(
|
||||
value = homePercentage,
|
||||
onValueChange = {
|
||||
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||
homePercentage = it
|
||||
job?.cancel()
|
||||
job = scope.launch {
|
||||
delay(500)
|
||||
if (bothEnabled) {
|
||||
onVignettePercentageChange(it.roundToInt(), lockPercentage.roundToInt())
|
||||
} else {
|
||||
onVignettePercentageChange(it.roundToInt(), it.roundToInt())
|
||||
}
|
||||
}
|
||||
},
|
||||
valueRange = 0f..100f,
|
||||
steps = 100,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||
)
|
||||
if (bothEnabled) {
|
||||
Text(
|
||||
text = stringResource(R.string.lock) + " | " + stringResource(R.string.percentage, lockPercentage.roundToInt()),
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp)),
|
||||
fontWeight = FontWeight.W400
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Slider(
|
||||
value = lockPercentage,
|
||||
onValueChange = {
|
||||
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||
lockPercentage = it
|
||||
job?.cancel()
|
||||
job = scope.launch {
|
||||
delay(500)
|
||||
onVignettePercentageChange(homePercentage.roundToInt(), it.roundToInt())
|
||||
}
|
||||
},
|
||||
valueRange = 0f..100f,
|
||||
steps = 100,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (vignette) {
|
||||
Column {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
if (bothEnabled) {
|
||||
Text(
|
||||
text = stringResource(R.string.home_screen) + " | " + stringResource(R.string.percentage, homePercentage.roundToInt()),
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp)),
|
||||
fontWeight = FontWeight.W400
|
||||
)
|
||||
}
|
||||
else {
|
||||
Text(
|
||||
text = stringResource(R.string.percentage, homePercentage.roundToInt()),
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp)),
|
||||
fontWeight = FontWeight.W400
|
||||
)
|
||||
}
|
||||
Slider(
|
||||
value = homePercentage,
|
||||
onValueChange = {
|
||||
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||
homePercentage = it
|
||||
job?.cancel()
|
||||
job = scope.launch {
|
||||
delay(500)
|
||||
if (bothEnabled) {
|
||||
onVignettePercentageChange(it.roundToInt(), lockPercentage.roundToInt())
|
||||
} else {
|
||||
onVignettePercentageChange(it.roundToInt(), it.roundToInt())
|
||||
}
|
||||
}
|
||||
},
|
||||
valueRange = 0f..100f,
|
||||
steps = 100,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||
)
|
||||
if (bothEnabled) {
|
||||
Text(
|
||||
text = stringResource(R.string.lock) + " | " + stringResource(R.string.percentage, lockPercentage.roundToInt()),
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp)),
|
||||
fontWeight = FontWeight.W400
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Slider(
|
||||
value = lockPercentage,
|
||||
onValueChange = {
|
||||
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||
lockPercentage = it
|
||||
job?.cancel()
|
||||
job = scope.launch {
|
||||
delay(500)
|
||||
onVignettePercentageChange(homePercentage.roundToInt(), it.roundToInt())
|
||||
}
|
||||
},
|
||||
valueRange = 0f..100f,
|
||||
steps = 100,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+9
-2
@@ -51,6 +51,9 @@ fun WallpaperPreviewAndScale(
|
||||
blur: Boolean,
|
||||
homeBlurPercentage: Int,
|
||||
lockBlurPercentage: Int,
|
||||
vignette: Boolean,
|
||||
homeVignettePercentage: Int,
|
||||
lockVignettePercentage: Int
|
||||
) {
|
||||
var selectedIndex by rememberSaveable {
|
||||
mutableIntStateOf(
|
||||
@@ -102,7 +105,9 @@ fun WallpaperPreviewAndScale(
|
||||
darkenPercentage = if (!homeEnabled) homeDarkenPercentage else lockDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercentage = if (!homeEnabled) homeBlurPercentage else lockBlurPercentage
|
||||
blurPercentage = if (!homeEnabled) homeBlurPercentage else lockBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercentage = if (!homeEnabled) homeVignettePercentage else lockVignettePercentage
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
@@ -121,7 +126,9 @@ fun WallpaperPreviewAndScale(
|
||||
darkenPercentage = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercentage = homeBlurPercentage
|
||||
blurPercentage = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercentage = homeVignettePercentage
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
|
||||
+30
-9
@@ -193,6 +193,8 @@ class HomeWallpaperService: Service() {
|
||||
val homeDarkenPercentage = settingsDataStoreImpl.getInt(SettingsConstants.HOME_DARKEN_PERCENTAGE) ?: 100
|
||||
val blur = settingsDataStoreImpl.getBoolean(SettingsConstants.BLUR) ?: false
|
||||
val homeBlurPercentage = settingsDataStoreImpl.getInt(SettingsConstants.HOME_BLUR_PERCENTAGE) ?: 0
|
||||
val vignette = settingsDataStoreImpl.getBoolean(SettingsConstants.VIGNETTE) ?: false
|
||||
val homeVignettePercentage = settingsDataStoreImpl.getInt(SettingsConstants.HOME_VIGNETTE_PERCENTAGE) ?: 0
|
||||
val homeAlbumName = settingsDataStoreImpl.getString(SettingsConstants.HOME_ALBUM_NAME) ?: ""
|
||||
val lockAlbumName = settingsDataStoreImpl.getString(SettingsConstants.LOCK_ALBUM_NAME) ?: ""
|
||||
var homeAlbum = selectedAlbum.find { it.album.initialAlbumName == homeAlbumName }
|
||||
@@ -220,7 +222,9 @@ class HomeWallpaperService: Service() {
|
||||
darkenPercent = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = homeBlurPercentage
|
||||
blurPercent = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = homeVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_HOME_WALLPAPER, if (newWallpapers.size > 1) newWallpapers[1] else homeAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
if (success) {
|
||||
@@ -252,7 +256,9 @@ class HomeWallpaperService: Service() {
|
||||
darkenPercent = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = homeBlurPercentage
|
||||
blurPercent = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = homeVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_HOME_WALLPAPER, if (homeAlbum.album.homeWallpapersInQueue.size > 1) homeAlbum.album.homeWallpapersInQueue[1] else homeAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
if ((homeInterval % lockInterval == 0) || (lockInterval % homeInterval == 0) && (homeAlbumName == lockAlbumName)) {
|
||||
@@ -302,7 +308,9 @@ class HomeWallpaperService: Service() {
|
||||
darkenPercent = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = homeBlurPercentage
|
||||
blurPercent = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = homeVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_HOME_WALLPAPER, if (homeAlbum.album.homeWallpapersInQueue.size > 1) homeAlbum.album.homeWallpapersInQueue[1] else homeAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
if (success) {
|
||||
@@ -336,7 +344,9 @@ class HomeWallpaperService: Service() {
|
||||
darkenPercent = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = homeBlurPercentage
|
||||
blurPercent = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = homeVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_HOME_WALLPAPER, if (homeAlbum.album.homeWallpapersInQueue.size > 1) homeAlbum.album.homeWallpapersInQueue[1] else homeAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
if (success) {
|
||||
@@ -392,7 +402,9 @@ class HomeWallpaperService: Service() {
|
||||
darkenPercent = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = homeBlurPercentage
|
||||
blurPercent = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = homeVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_HOME_WALLPAPER, if (homeAlbum.album.homeWallpapersInQueue.size > 1) homeAlbum.album.homeWallpapersInQueue[1] else homeAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_LOCK_WALLPAPER, if (homeAlbum.album.homeWallpapersInQueue.size > 1) homeAlbum.album.homeWallpapersInQueue[1] else homeAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
@@ -427,7 +439,9 @@ class HomeWallpaperService: Service() {
|
||||
darkenPercent = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = homeBlurPercentage
|
||||
blurPercent = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = homeVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_HOME_WALLPAPER, if (homeAlbum.album.homeWallpapersInQueue.size > 1) homeAlbum.album.homeWallpapersInQueue[1] else homeAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_LOCK_WALLPAPER, if (homeAlbum.album.homeWallpapersInQueue.size > 1) homeAlbum.album.homeWallpapersInQueue[1] else homeAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
@@ -517,6 +531,9 @@ class HomeWallpaperService: Service() {
|
||||
val blur = settingsDataStoreImpl.getBoolean(SettingsConstants.BLUR) ?: false
|
||||
val homeBlurPercentage = settingsDataStoreImpl.getInt(SettingsConstants.HOME_BLUR_PERCENTAGE) ?: 0
|
||||
val currentHomeWallpaper = settingsDataStoreImpl.getString(SettingsConstants.CURRENT_HOME_WALLPAPER) ?: ""
|
||||
val vignette = settingsDataStoreImpl.getBoolean(SettingsConstants.VIGNETTE) ?: false
|
||||
val homeVignettePercentage = settingsDataStoreImpl.getInt(SettingsConstants.HOME_VIGNETTE_PERCENTAGE) ?: 0
|
||||
|
||||
setWallpaper(
|
||||
context = context,
|
||||
wallpaper = currentHomeWallpaper.toUri(),
|
||||
@@ -524,7 +541,9 @@ class HomeWallpaperService: Service() {
|
||||
darkenPercent = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = homeBlurPercentage
|
||||
blurPercent = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = homeVignettePercentage
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -541,8 +560,10 @@ class HomeWallpaperService: Service() {
|
||||
darken: Boolean,
|
||||
darkenPercent: Int,
|
||||
scaling: ScalingConstants,
|
||||
blur: Boolean = false,
|
||||
blur: Boolean,
|
||||
blurPercent: Int,
|
||||
vignette: Boolean,
|
||||
vignettePercent: Int
|
||||
): Boolean {
|
||||
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||
try {
|
||||
@@ -550,7 +571,7 @@ class HomeWallpaperService: Service() {
|
||||
val bitmap = retrieveBitmap(context, wallpaper, device)
|
||||
if (bitmap == null) return false
|
||||
else {
|
||||
processBitmap(device, bitmap, darken, darkenPercent, scaling, blur, blurPercent)?.let { image ->
|
||||
processBitmap(device, bitmap, darken, darkenPercent, scaling, blur, blurPercent, vignette, vignettePercent)?.let { image ->
|
||||
wallpaperManager.setBitmap(image, null, true, WallpaperManager.FLAG_SYSTEM)
|
||||
wallpaperManager.forgetLoadedWallpaper()
|
||||
image.recycle()
|
||||
|
||||
+29
-8
@@ -194,6 +194,9 @@ class LockWallpaperService: Service() {
|
||||
val blur = settingsDataStoreImpl.getBoolean(SettingsConstants.BLUR) ?: false
|
||||
val homeBlurPercentage = settingsDataStoreImpl.getInt(SettingsConstants.HOME_BLUR_PERCENTAGE) ?: 0
|
||||
val lockBlurPercentage = settingsDataStoreImpl.getInt(SettingsConstants.LOCK_BLUR_PERCENTAGE) ?: 0
|
||||
val vignette = settingsDataStoreImpl.getBoolean(SettingsConstants.VIGNETTE) ?: false
|
||||
val homeVignettePercentage = settingsDataStoreImpl.getInt(SettingsConstants.HOME_VIGNETTE_PERCENTAGE) ?: 0
|
||||
val lockVignettePercentage = settingsDataStoreImpl.getInt(SettingsConstants.LOCK_VIGNETTE_PERCENTAGE) ?: 0
|
||||
val lockAlbumName = settingsDataStoreImpl.getString(SettingsConstants.LOCK_ALBUM_NAME) ?: ""
|
||||
val lockAlbum = selectedAlbum.find { it.album.initialAlbumName == lockAlbumName }
|
||||
if (lockAlbum == null) {
|
||||
@@ -220,7 +223,9 @@ class LockWallpaperService: Service() {
|
||||
darkenPercent = lockDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = lockBlurPercentage
|
||||
blurPercent = lockBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = lockVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_LOCK_WALLPAPER, if (newWallpapers.size > 1) newWallpapers[1] else lockAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
if (success) {
|
||||
@@ -252,7 +257,9 @@ class LockWallpaperService: Service() {
|
||||
darkenPercent = lockDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = lockBlurPercentage
|
||||
blurPercent = lockBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = lockVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_LOCK_WALLPAPER, if (lockAlbum.album.lockWallpapersInQueue.size > 1) lockAlbum.album.lockWallpapersInQueue[1] else lockAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
if (success) {
|
||||
@@ -298,7 +305,9 @@ class LockWallpaperService: Service() {
|
||||
darkenPercent = lockDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = lockBlurPercentage
|
||||
blurPercent = lockBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = lockVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_LOCK_WALLPAPER, if (homeAlbum.album.homeWallpapersInQueue.size > 1) homeAlbum.album.homeWallpapersInQueue[1] else homeAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
if (success) {
|
||||
@@ -325,7 +334,9 @@ class LockWallpaperService: Service() {
|
||||
darkenPercent = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = homeBlurPercentage
|
||||
blurPercent = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = homeVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_LOCK_WALLPAPER, if (newWallpapers.size > 1) newWallpapers[1] else lockAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_HOME_WALLPAPER, if (newWallpapers.size > 1) newWallpapers[1] else lockAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
@@ -359,7 +370,9 @@ class LockWallpaperService: Service() {
|
||||
darkenPercent = homeDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = homeBlurPercentage
|
||||
blurPercent = homeBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = homeVignettePercentage
|
||||
)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_LOCK_WALLPAPER, if (lockAlbum.album.lockWallpapersInQueue.size > 1) lockAlbum.album.lockWallpapersInQueue[1] else lockAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_HOME_WALLPAPER, if (lockAlbum.album.lockWallpapersInQueue.size > 1) lockAlbum.album.lockWallpapersInQueue[1] else lockAlbum.wallpapers.firstOrNull()?.wallpaperUri ?: "")
|
||||
@@ -439,7 +452,11 @@ class LockWallpaperService: Service() {
|
||||
val blur = settingsDataStoreImpl.getBoolean(SettingsConstants.BLUR) ?: false
|
||||
val homeBlurPercentage = settingsDataStoreImpl.getInt(SettingsConstants.HOME_BLUR_PERCENTAGE) ?: 0
|
||||
val lockBlurPercentage = settingsDataStoreImpl.getInt(SettingsConstants.LOCK_BLUR_PERCENTAGE) ?: 0
|
||||
val vignette = settingsDataStoreImpl.getBoolean(SettingsConstants.VIGNETTE) ?: false
|
||||
val homeVignettePercentage = settingsDataStoreImpl.getInt(SettingsConstants.HOME_VIGNETTE_PERCENTAGE) ?: 0
|
||||
val lockVignettePercentage = settingsDataStoreImpl.getInt(SettingsConstants.LOCK_VIGNETTE_PERCENTAGE) ?: 0
|
||||
val currentLockWallpaper = settingsDataStoreImpl.getString(SettingsConstants.CURRENT_LOCK_WALLPAPER) ?: ""
|
||||
|
||||
setWallpaper(
|
||||
context = context,
|
||||
wallpaper = currentLockWallpaper.toUri(),
|
||||
@@ -447,7 +464,9 @@ class LockWallpaperService: Service() {
|
||||
darkenPercent = if (!setHome) homeDarkenPercentage else lockDarkenPercentage,
|
||||
scaling = scaling,
|
||||
blur = blur,
|
||||
blurPercent = if (!setHome) homeBlurPercentage else lockBlurPercentage
|
||||
blurPercent = if (!setHome) homeBlurPercentage else lockBlurPercentage,
|
||||
vignette = vignette,
|
||||
vignettePercent = if (!setHome) homeVignettePercentage else lockVignettePercentage
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -464,8 +483,10 @@ class LockWallpaperService: Service() {
|
||||
darken: Boolean,
|
||||
darkenPercent: Int,
|
||||
scaling: ScalingConstants,
|
||||
blur: Boolean = false,
|
||||
blur: Boolean,
|
||||
blurPercent: Int,
|
||||
vignette: Boolean,
|
||||
vignettePercent: Int
|
||||
): Boolean {
|
||||
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||
try {
|
||||
@@ -473,7 +494,7 @@ class LockWallpaperService: Service() {
|
||||
val bitmap = retrieveBitmap(context, wallpaper, device)
|
||||
if (bitmap == null) return false
|
||||
else {
|
||||
processBitmap(device, bitmap, darken, darkenPercent, scaling, blur, blurPercent)?.let { image ->
|
||||
processBitmap(device, bitmap, darken, darkenPercent, scaling, blur, blurPercent, vignette, vignettePercent)?.let { image ->
|
||||
wallpaperManager.setBitmap(image, null, true, WallpaperManager.FLAG_LOCK)
|
||||
wallpaperManager.forgetLoadedWallpaper()
|
||||
image.recycle()
|
||||
|
||||
Reference in new issue
Block a user