Skip to content

Commit

Permalink
Updated dependencies
Browse files Browse the repository at this point in the history
Updated navigation for FolderView to type-safe navigation
Updated error checking for tab navigation
  • Loading branch information
Anthonyy232 committed Jul 5, 2024
1 parent bcff2f3 commit c1404ec
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 80 deletions.
62 changes: 34 additions & 28 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,55 @@ android {
targetSdk = 34
versionCode = 24
versionName = "1.5.6"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
ndk {
debugSymbolLevel = "FULL"
}
}


buildTypes {
release {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
ndk {
debugSymbolLevel = "FULL"
}
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += strongSkippingConfiguration()
}

buildFeatures {
compose = true
viewBinding = true
buildConfig = true
}

composeOptions {
kotlinCompilerExtensionVersion = "1.5.10"
}

androidResources {
generateLocaleConfig = true
}

ndkVersion = "26.3.11579264"
buildToolsVersion = "34.0.0"
dependenciesInfo {
includeInApk = true
includeInBundle = true
}

aboutLibraries {
excludeFields = arrayOf("generated")
Expand All @@ -77,47 +84,46 @@ androidComponents {

dependencies {
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.2")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3")
implementation("androidx.activity:activity-compose:1.9.0")
implementation(platform("androidx.compose:compose-bom:2024.06.00"))
implementation("androidx.compose.ui:ui:1.7.0-beta03")
implementation("androidx.compose.ui:ui-graphics:1.7.0-beta03")
implementation("androidx.compose.ui:ui-tooling-preview:1.7.0-beta03")
implementation("androidx.compose.material3:material3:1.3.0-beta03")
implementation("androidx.navigation:navigation-compose:2.8.0-beta03")
implementation("androidx.compose.material:material:1.7.0-beta03")
implementation("androidx.compose.ui:ui:1.7.0-beta04")
implementation("androidx.compose.ui:ui-graphics:1.7.0-beta04")
implementation("androidx.compose.ui:ui-tooling-preview:1.7.0-beta04")
implementation("androidx.compose.material3:material3:1.3.0-beta04")
implementation("androidx.navigation:navigation-compose:2.8.0-beta04")
implementation("androidx.compose.material:material:1.7.0-beta04")
implementation("androidx.datastore:datastore:1.1.1")
implementation("androidx.datastore:datastore-preferences:1.1.1")
implementation("androidx.compose.material:material-icons-extended:1.7.0-beta03")
implementation("com.google.accompanist:accompanist-adaptive:0.35.1-alpha")
implementation("androidx.compose.material:material-icons-extended:1.7.0-beta04")
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
implementation("androidx.compose.animation:animation:1.7.0-beta03")
implementation("androidx.compose.animation:animation:1.7.0-beta04")
implementation("androidx.core:core-splashscreen:1.2.0-alpha01")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.2")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.3")
implementation("com.google.code.gson:gson:2.11.0")
implementation("androidx.documentfile:documentfile:1.1.0-alpha01")
implementation("net.engawapg.lib:zoomable:2.0.0-beta01")
implementation("com.github.skydoves:landscapist-glide:2.3.4")
implementation("net.engawapg.lib:zoomable:1.7.0-beta02")
implementation("com.github.skydoves:landscapist-glide:2.3.6")
implementation("androidx.work:work-runtime-ktx:2.10.0-alpha02")
implementation("androidx.hilt:hilt-work:1.2.0")
implementation("com.airbnb.android:lottie-compose:6.4.1")
implementation("com.google.accompanist:accompanist-permissions:0.35.1-alpha")
implementation("com.mikepenz:aboutlibraries-core:11.2.1")
implementation("com.mikepenz:aboutlibraries-compose-m3:11.2.1")
implementation("androidx.compose.foundation:foundation:1.7.0-beta03")
implementation("com.google.accompanist:accompanist-permissions:0.35.0-alpha")
implementation("com.mikepenz:aboutlibraries-core:11.2.2")
implementation("com.mikepenz:aboutlibraries-compose-m3:11.2.2")
implementation("androidx.compose.foundation:foundation:1.7.0-beta04")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.0-rc01")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.0-beta03")
debugImplementation("androidx.compose.ui:ui-tooling:1.7.0-beta03")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.0-beta03")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.0-beta04")
debugImplementation("androidx.compose.ui:ui-tooling:1.7.0-beta04")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.0-beta04")
implementation("com.google.dagger:hilt-android:2.51.1")
ksp("com.google.dagger:hilt-android-compiler:2.51.1")
implementation("androidx.room:room-runtime:2.6.1")
ksp("androidx.room:room-compiler:2.6.1")
implementation("androidx.room:room-ktx:2.6.1")
implementation("com.lazygeniouz:dfc:1.0.8")
implementation ("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0")
implementation ("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
implementation("com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ import androidx.compose.ui.unit.Dp
import androidx.core.content.ContextCompat
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import androidx.navigation.toRoute
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
Expand All @@ -45,10 +43,10 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.Wa
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_view_screen.WallpaperViewScreen
import com.anthonyla.paperize.feature.wallpaper.util.navigation.AddEdit
import com.anthonyla.paperize.feature.wallpaper.util.navigation.AlbumView
import com.anthonyla.paperize.feature.wallpaper.util.navigation.FolderView
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Home
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Licenses
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavConstants.INITIAL_OFFSET
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavScreens
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Notification
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Privacy
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Settings
Expand All @@ -58,15 +56,11 @@ import com.anthonyla.paperize.feature.wallpaper.util.navigation.sharedXTransitio
import com.anthonyla.paperize.feature.wallpaper.util.navigation.sharedXTransitionOut
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperAlarmItem
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperScheduler
import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import java.net.URLEncoder
import java.nio.charset.StandardCharsets

@Composable
fun PaperizeApp(
Expand Down Expand Up @@ -100,9 +94,7 @@ fun PaperizeApp(
navController.navigate(Home)
}
}
albumsViewModel.onEvent(
AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpapers)
)
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpapers))
}
}
selectedState.value.selectedAlbum?.let { selectedAlbum ->
Expand Down Expand Up @@ -565,8 +557,7 @@ fun PaperizeApp(
navController.navigate(WallpaperView(it))
},
onShowFolderView = { folderName, wallpapers ->
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
navController.navigate("${NavScreens.FolderView.route}/${folderName ?: " "}/$encodedWallpapers")
navController.navigate(FolderView(folderName, wallpapers))
}
)
}
Expand Down Expand Up @@ -600,12 +591,7 @@ fun PaperizeApp(
animate = settingsState.value.animate
)
}
composable(
route = NavScreens.FolderView.route.plus("/{folderName}/{wallpapers}"),
arguments = listOf(
navArgument("folderName") { type = NavType.StringType },
navArgument("wallpapers") { type = NavType.StringType }
),
composable<FolderView>(
enterTransition = {
if (settingsState.value.animate) {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
Expand All @@ -627,15 +613,11 @@ fun PaperizeApp(
} else { null }
}
) { backStackEntry ->
val folderName = backStackEntry.arguments?.getString("folderName")
val wallpapers = Gson().fromJson(
backStackEntry.arguments?.getString("wallpapers"),
Array<String>::class.java
).toList()
if (wallpapers.isNotEmpty()) {
val folderView: FolderView = backStackEntry.toRoute()
if (folderView.wallpapers.isNotEmpty()) {
FolderViewScreen(
folderName = folderName,
wallpapers = wallpapers,
folderName = folderView.folderName,
wallpapers = folderView.wallpapers,
onBackClick = { navController.navigateUp() },
onShowWallpaperView = {
navController.navigate(WallpaperView(it))
Expand Down Expand Up @@ -677,8 +659,7 @@ fun PaperizeApp(
navController.navigate(WallpaperView(it))
},
onShowFolderView = { folderName, wallpapers ->
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
navController.navigate("${NavScreens.FolderView.route}/${folderName ?: " "}/$encodedWallpapers")
navController.navigate(FolderView(folderName, wallpapers))
},
onDeleteAlbum = {
navController.navigateUp()
Expand Down Expand Up @@ -806,10 +787,4 @@ fun PaperizeApp(
)
}
}
}

// Encode an URI so it can be passed with navigation
suspend fun encodeUri(uri: String): String =
withContext(Dispatchers.IO) {
URLEncoder.encode(uri, StandardCharsets.UTF_8.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ fun AddAlbumSmallTopBar(
), label = stringResource(R.string.circle_3_animation)
)


TopAppBar(
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = MaterialTheme.colorScheme.surface),
title = {
Expand Down Expand Up @@ -174,7 +173,7 @@ fun AddAlbumSmallTopBar(
},
actions = {
if(!selectionMode) {
if (!isEmpty) {
if (!isEmpty && editableTitle.isNotEmpty()) {
Box {
val primaryColor = MaterialTheme.colorScheme.inversePrimary
val secondaryColor = MaterialTheme.colorScheme.secondary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fun HomeScreen(
TabRow(
selectedTabIndex = tabIndex,
indicator = { tabPositions ->
if (tabIndex < tabPositions.size) {
if (tabIndex in tabPositions.indices) {
TabRowDefaults.PrimaryIndicator(
modifier = Modifier.tabIndicatorOffset(tabPositions[tabIndex]),
shape = RoundedCornerShape(
Expand Down Expand Up @@ -129,7 +129,7 @@ fun HomeScreen(
state = pagerState,
beyondViewportPageCount = 1
) { index ->
when(index) {
when(index.coerceIn(tabItems.indices)) {
0 -> WallpaperScreen(
animate = animate,
darken = darken,
Expand Down Expand Up @@ -162,7 +162,7 @@ fun HomeScreen(
onBlurChange = onBlurChange,
blurPercentage = blurPercentage
)
1 -> LibraryScreen(
else -> LibraryScreen(
onAddNewAlbumClick = { addAlbumDialog = true },
onViewAlbum = onAlbumViewClick,
animate = animate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,8 @@ data class AddEdit(val wallpaper: String)
@Serializable
data class WallpaperView(val wallpaper: String)

/** Reverted back to passing JSON due to bug in navigation compose causing crash
/**
* Data class for FolderView screen
*/
@Serializable
data class FolderView(val folderName: String?, val wallpapers: List<String>)
*/

sealed class NavScreens(val route: String) {
data object FolderView : NavScreens("folder_view_screen")
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import javax.inject.Inject
import kotlin.math.min

/**
* Used in conjunction with [WallpaperService1] to schedule home screen and lock screen separately
* Used in conjunction with [WallpaperService1] to schedule home screen and lock screen separately -- sets lock screen wallpaper
*/
@AndroidEntryPoint
class WallpaperService2: Service() {
Expand Down Expand Up @@ -238,7 +238,7 @@ class WallpaperService2: Service() {
setLock = setLock,
setLockOrHome = setHomeOrLock,
blur = blur,
blurPercent = blurPercentage,
blurPercent = blurPercentage
)) {
selectedAlbum.wallpapers.firstOrNull { it.wallpaperUri == wallpaper }
?.let { it1 ->
Expand Down Expand Up @@ -326,7 +326,7 @@ class WallpaperService2: Service() {
setHome = setHome,
setLock = setLock,
blur = blur,
blurPercent = blurPercentage,
blurPercent = blurPercentage
)) {
selectedAlbum.wallpapers.firstOrNull { it.wallpaperUri == wallpaper }
?.let { it1 ->
Expand Down Expand Up @@ -370,7 +370,7 @@ class WallpaperService2: Service() {
setLock = setLock,
setLockOrHome = setHomeOrLock,
blur = blur,
blurPercent = blurPercentage,
blurPercent = blurPercentage
)
) {
selectedAlbum.wallpapers.firstOrNull { it.wallpaperUri == wallpaper }
Expand Down Expand Up @@ -513,7 +513,6 @@ class WallpaperService2: Service() {
setLockOrHome: Boolean? = null,
blur: Boolean = false,
blurPercent: Int,
lastHomeWallpaper: Uri? = null,
): Boolean {
val wallpaperManager = WallpaperManager.getInstance(context)
try {
Expand Down Expand Up @@ -564,8 +563,8 @@ class WallpaperService2: Service() {
image.recycle()
}
bitmap.recycle()
return true
}
return true
} catch (e: IOException) {
Log.e("PaperizeWallpaperChanger", "Error setting wallpaper", e)
return false
Expand Down

0 comments on commit c1404ec

Please sign in to comment.