diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 17507ec3..b5618550 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -20,7 +20,7 @@ android { minSdk = 26 targetSdk = 35 versionCode = 31 - versionName = "2.1.1" + versionName = "2.2.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true @@ -113,6 +113,7 @@ dependencies { implementation("androidx.compose.foundation:foundation:1.7.0") implementation("com.github.nanihadesuka:LazyColumnScrollbar:2.2.0") implementation("com.joaomgcd:taskerpluginlibrary:0.4.10") + implementation("com.google.ar.sceneform:filament-android:1.17.1") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.2.1") androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") diff --git a/app/src/main/java/com/anthonyla/paperize/core/ScalingConstants.kt b/app/src/main/java/com/anthonyla/paperize/core/ScalingConstants.kt index 54818163..7da70009 100644 --- a/app/src/main/java/com/anthonyla/paperize/core/ScalingConstants.kt +++ b/app/src/main/java/com/anthonyla/paperize/core/ScalingConstants.kt @@ -3,5 +3,6 @@ package com.anthonyla.paperize.core enum class ScalingConstants { FIT, FILL, - STRETCH + STRETCH, + NONE } \ No newline at end of file diff --git a/app/src/main/java/com/anthonyla/paperize/core/WallpaperUtil.kt b/app/src/main/java/com/anthonyla/paperize/core/WallpaperUtil.kt index fc643b24..9da47603 100644 --- a/app/src/main/java/com/anthonyla/paperize/core/WallpaperUtil.kt +++ b/app/src/main/java/com/anthonyla/paperize/core/WallpaperUtil.kt @@ -84,7 +84,6 @@ object ScreenMetricsCompat { private val api: Api = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) ApiLevel30() else Api() fun getScreenSize(context: Context): Size = api.getScreenSize(context) - @Suppress("DEPRECATION") private open class Api { open fun getScreenSize(context: Context): Size { @@ -457,6 +456,7 @@ fun processBitmap( ScalingConstants.FILL -> fillBitmap(processedBitmap, width, height) ScalingConstants.FIT -> fitBitmap(processedBitmap, width, height) ScalingConstants.STRETCH -> stretchBitmap(processedBitmap, width, height) + ScalingConstants.NONE -> processedBitmap } // Apply brightness effect diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/wallpaper_screen/components/PreviewItem.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/wallpaper_screen/components/PreviewItem.kt index a7b53538..0a568659 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/wallpaper_screen/components/PreviewItem.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/wallpaper_screen/components/PreviewItem.kt @@ -54,9 +54,10 @@ fun PreviewItem( ScalingConstants.FILL -> ContentScale.FillHeight ScalingConstants.FIT -> ContentScale.FillWidth ScalingConstants.STRETCH -> ContentScale.FillBounds + ScalingConstants.NONE -> ContentScale.Crop }, requestSize = IntSize(300, 300), - alignment = Alignment.Center, + alignment = if (scaling == ScalingConstants.NONE) Alignment.CenterStart else Alignment.Center, colorFilter = if (darken && darkenPercentage < 100) { ColorFilter.tint( Color.Black.copy(alpha = (100 - darkenPercentage).toFloat().div(100f)), diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/wallpaper_screen/components/WallpaperPreviewAndScale.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/wallpaper_screen/components/WallpaperPreviewAndScale.kt index e5ac0eaf..451f234e 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/wallpaper_screen/components/WallpaperPreviewAndScale.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/wallpaper_screen/components/WallpaperPreviewAndScale.kt @@ -61,13 +61,15 @@ fun WallpaperPreviewAndScale( ScalingConstants.FILL -> 0 ScalingConstants.FIT -> 1 ScalingConstants.STRETCH -> 2 + ScalingConstants.NONE -> 3 } ) } val options = listOf( stringResource(R.string.fill), stringResource(R.string.fit), - stringResource(R.string.stretch) + stringResource(R.string.stretch), + stringResource(R.string.none) ) Surface( @@ -87,9 +89,13 @@ fun WallpaperPreviewAndScale( verticalAlignment = Alignment.CenterVertically ) { val modifier = if (lockEnabled && homeEnabled) { - Modifier.weight(1f).padding(8.dp) + Modifier + .weight(1f) + .padding(8.dp) } else { - Modifier.fillMaxSize(0.5f).padding(8.dp) + Modifier + .fillMaxSize(0.5f) + .padding(8.dp) } if (lockEnabled) { @@ -150,6 +156,7 @@ fun WallpaperPreviewAndScale( 0 -> ScalingConstants.FILL 1 -> ScalingConstants.FIT 2 -> ScalingConstants.STRETCH + 3 -> ScalingConstants.NONE else -> ScalingConstants.FILL } ) }, @@ -164,6 +171,7 @@ fun WallpaperPreviewAndScale( 0 -> painterResource(id = R.drawable.fill) 1 -> painterResource(id = R.drawable.fit) 2 -> painterResource(id = R.drawable.stretch) + 3 -> painterResource(id = R.drawable.none) else -> painterResource(id = R.drawable.fill) }, contentDescription = null, diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/wallpaper_service/HomeWallpaperService.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/wallpaper_service/HomeWallpaperService.kt index bd53c27b..ceb19daa 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/wallpaper_service/HomeWallpaperService.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/wallpaper_service/HomeWallpaperService.kt @@ -42,6 +42,7 @@ import java.time.format.DateTimeFormatter import java.time.format.FormatStyle import javax.inject.Inject + /** * Service for changing home screen */ @@ -571,7 +572,7 @@ class HomeWallpaperService: Service() { val size = getDeviceScreenSize(context) val bitmap = retrieveBitmap(context, wallpaper, size.width, size.height) if (bitmap == null) return false - else { + else if (wallpaperManager.isSetWallpaperAllowed) { processBitmap(size.width, size.height, bitmap, darken, darkenPercent, scaling, blur, blurPercent, vignette, vignettePercent)?.let { image -> wallpaperManager.setBitmap(image, null, true, WallpaperManager.FLAG_SYSTEM) wallpaperManager.forgetLoadedWallpaper() @@ -580,6 +581,7 @@ class HomeWallpaperService: Service() { bitmap.recycle() return true } + else return false } catch (e: IOException) { Log.e("PaperizeWallpaperChanger", "Error setting wallpaper", e) return false diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/wallpaper_service/LockWallpaperService.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/wallpaper_service/LockWallpaperService.kt index 5493bd6b..7b56cb4f 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/wallpaper_service/LockWallpaperService.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/wallpaper_service/LockWallpaperService.kt @@ -494,7 +494,7 @@ class LockWallpaperService: Service() { val size = getDeviceScreenSize(context) val bitmap = retrieveBitmap(context, wallpaper, size.width, size.height) if (bitmap == null) return false - else { + else if (wallpaperManager.isSetWallpaperAllowed) { processBitmap(size.width, size.height, bitmap, darken, darkenPercent, scaling, blur, blurPercent, vignette, vignettePercent)?.let { image -> wallpaperManager.setBitmap(image, null, true, WallpaperManager.FLAG_LOCK) wallpaperManager.forgetLoadedWallpaper() @@ -503,6 +503,7 @@ class LockWallpaperService: Service() { bitmap.recycle() return true } + else return false } catch (e: IOException) { Log.e("PaperizeWallpaperChanger", "Error setting wallpaper", e) return false diff --git a/app/src/main/res/drawable/none.xml b/app/src/main/res/drawable/none.xml new file mode 100644 index 00000000..495818c7 --- /dev/null +++ b/app/src/main/res/drawable/none.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b1513220..779cd19d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -163,4 +163,5 @@ Unselected album Lock Change Vignette + None \ No newline at end of file