Added comments to code
This commit is contained in:
1 parent
87534f8523
commit
0f975c9b20
49 files changed
+344
-158
No files matched your search
+13
-13
@@ -60,20 +60,20 @@ dependencies {
|
||||
implementation("androidx.core:core-ktx:1.12.0")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
|
||||
implementation("androidx.activity:activity-compose:1.8.2")
|
||||
implementation(platform("androidx.compose:compose-bom:2024.03.00"))
|
||||
implementation("androidx.compose.ui:ui:1.6.4")
|
||||
implementation("androidx.compose.ui:ui-graphics:1.6.4")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview:1.6.4")
|
||||
implementation(platform("androidx.compose:compose-bom:2024.04.00"))
|
||||
implementation("androidx.compose.ui:ui:1.6.5")
|
||||
implementation("androidx.compose.ui:ui-graphics:1.6.5")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview:1.6.5")
|
||||
implementation("androidx.compose.material3:material3:1.2.1")
|
||||
implementation("androidx.navigation:navigation-compose:2.7.7")
|
||||
implementation("androidx.compose.material:material:1.6.4")
|
||||
implementation("androidx.datastore:datastore:1.1.0-beta02")
|
||||
implementation("androidx.datastore:datastore-preferences:1.1.0-beta02")
|
||||
implementation("androidx.compose.material:material-icons-extended:1.6.4")
|
||||
implementation("androidx.compose.material:material:1.6.5")
|
||||
implementation("androidx.datastore:datastore:1.1.0-rc01")
|
||||
implementation("androidx.datastore:datastore-preferences:1.1.0-rc01")
|
||||
implementation("androidx.compose.material:material-icons-extended:1.6.5")
|
||||
implementation("com.google.accompanist:accompanist-adaptive:0.34.0")
|
||||
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
|
||||
implementation("androidx.compose.animation:animation:1.6.4")
|
||||
implementation("androidx.core:core-splashscreen:1.1.0-alpha02")
|
||||
implementation("androidx.compose.animation:animation:1.6.5")
|
||||
implementation("androidx.core:core-splashscreen:1.1.0-rc01")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
implementation("androidx.documentfile:documentfile:1.1.0-alpha01")
|
||||
@@ -82,9 +82,9 @@ dependencies {
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.0-alpha03")
|
||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.6.4")
|
||||
debugImplementation("androidx.compose.ui:ui-tooling:1.6.4")
|
||||
debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.4")
|
||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.6.5")
|
||||
debugImplementation("androidx.compose.ui:ui-tooling:1.6.5")
|
||||
debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.5")
|
||||
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")
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<activity
|
||||
android:name=".feature.wallpaper.presentation.MainActivity"
|
||||
android:exported="true"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:theme="@style/Theme.Paperize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.anthonyla.paperize
|
||||
import android.app.Application
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
||||
/**
|
||||
* Application class for Hilt
|
||||
*/
|
||||
@HiltAndroidApp
|
||||
class App: Application() {
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.anthonyla.paperize.core
|
||||
|
||||
/**
|
||||
* Constants for application settings
|
||||
*/
|
||||
object SettingsConstants {
|
||||
const val SETTINGS_DATASTORE = "settings_datastore"
|
||||
const val DARK_MODE_TYPE = "dark_mode_type"
|
||||
|
||||
@@ -6,6 +6,9 @@ import android.net.Uri
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
|
||||
/**
|
||||
* Opens an email intent to contact the developer.
|
||||
*/
|
||||
@Composable
|
||||
fun Contact(context: Context) {
|
||||
val authorEmail = "anthonyyla.dev@gmail.com"
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.anthonyla.paperize.data.settings
|
||||
|
||||
/**
|
||||
* Interface for the data store that handles the settings for application
|
||||
*/
|
||||
interface SettingsDataStore {
|
||||
suspend fun putBoolean(key: String, value: Boolean)
|
||||
suspend fun putString(key: String, value: String)
|
||||
|
||||
@@ -18,6 +18,9 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* AppModule provides dependencies for the application for Dagger Hilt to inject
|
||||
*/
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
object AppModule {
|
||||
|
||||
+3
@@ -13,6 +13,9 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
/**
|
||||
* Data access object for AlbumWithWallpaperAndFolder which is used for application's list of user albums
|
||||
*/
|
||||
@Dao
|
||||
interface AlbumDao {
|
||||
|
||||
|
||||
+4
@@ -7,6 +7,10 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Album
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
|
||||
/**
|
||||
* Database for storing albums, wallpapers, and folders
|
||||
* Stores [Album], [Wallpaper], and [Folder] inside AlbumWithWallpaperAndFolder
|
||||
*/
|
||||
@Database(
|
||||
entities = [Album::class, Wallpaper::class, Folder::class],
|
||||
version = 1
|
||||
|
||||
+9
@@ -3,12 +3,21 @@ package com.anthonyla.paperize.feature.wallpaper.data.data_source
|
||||
import androidx.room.TypeConverter
|
||||
import com.google.gson.Gson
|
||||
|
||||
/**
|
||||
* Converters for Room database to convert list of strings to json string and vice versa
|
||||
*/
|
||||
class Converters {
|
||||
private val gson = Gson()
|
||||
|
||||
/**
|
||||
* Convert list of strings to json string
|
||||
*/
|
||||
@TypeConverter
|
||||
fun listToJsonString(value: List<String>?): String = gson.toJson(value)
|
||||
|
||||
/**
|
||||
* Convert json string to list of strings
|
||||
*/
|
||||
@TypeConverter
|
||||
fun jsonStringToList(value: String) = gson.fromJson(value, Array<String>::class.java).toList()
|
||||
}
|
||||
+3
@@ -12,6 +12,9 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
/**
|
||||
* Data Access Object for selected album for application to keep track of which album is currently selected for changing wallpapers from
|
||||
*/
|
||||
@Dao
|
||||
interface SelectedAlbumDao {
|
||||
|
||||
|
||||
+4
@@ -6,6 +6,10 @@ import androidx.room.TypeConverters
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Album
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
|
||||
/**
|
||||
* Database for selected album
|
||||
* Stores [Album] and [Wallpaper] inside SelectedAlbum
|
||||
*/
|
||||
@Database(
|
||||
entities = [Album::class, Wallpaper::class],
|
||||
version = 1
|
||||
|
||||
@@ -3,6 +3,13 @@ package com.anthonyla.paperize.feature.wallpaper.domain.model
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
/**
|
||||
* Album model
|
||||
*
|
||||
* @param initialAlbumName The initial album name -- should not be changed as it is used as the key for database queries
|
||||
* @param displayedAlbumName The displayed album name
|
||||
* @param coverUri The cover uri of the album
|
||||
*/
|
||||
@Entity
|
||||
data class Album(
|
||||
@PrimaryKey(autoGenerate = false) val initialAlbumName: String,
|
||||
|
||||
+6
@@ -3,6 +3,12 @@ package com.anthonyla.paperize.feature.wallpaper.domain.model
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Relation
|
||||
|
||||
/**
|
||||
* Complete data class that represents an album with its wallpapers and folders.
|
||||
* @param album The album.
|
||||
* @param wallpapers The wallpapers.
|
||||
* @param folders The folders.
|
||||
*/
|
||||
data class AlbumWithWallpaperAndFolder(
|
||||
@Embedded val album: Album,
|
||||
@Relation(
|
||||
|
||||
@@ -3,6 +3,15 @@ package com.anthonyla.paperize.feature.wallpaper.domain.model
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
/**
|
||||
* Represents a folder directory containing wallpapers.
|
||||
*
|
||||
* @param initialAlbumName The initial album name.
|
||||
* @param folderName The folder name.
|
||||
* @param coverUri The cover URI.
|
||||
* @param wallpapers The list of wallpaper URI strings.
|
||||
* @param folderUri The folder directory URI.
|
||||
*/
|
||||
@Entity
|
||||
data class Folder(
|
||||
val initialAlbumName: String,
|
||||
|
||||
+5
@@ -3,6 +3,11 @@ package com.anthonyla.paperize.feature.wallpaper.domain.model
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Relation
|
||||
|
||||
/**
|
||||
* Data class that represents a selected album with its wallpapers.
|
||||
* @param album the selected album.
|
||||
* @param wallpapers the wallpapers of the selected album. Includes the wallpapers from each folders in album.
|
||||
*/
|
||||
data class SelectedAlbum(
|
||||
@Embedded val album: Album,
|
||||
@Relation(
|
||||
|
||||
@@ -3,6 +3,12 @@ package com.anthonyla.paperize.feature.wallpaper.domain.model
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
/**
|
||||
* Represents a wallpaper object.
|
||||
*
|
||||
* @param initialAlbumName The name of the album the wallpaper belongs to.
|
||||
* @param wallpaperUri The URI of the wallpaper.
|
||||
*/
|
||||
@Entity
|
||||
data class Wallpaper(
|
||||
val initialAlbumName: String,
|
||||
|
||||
+70
@@ -7,23 +7,93 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface AlbumRepository {
|
||||
/**
|
||||
* Get all albums with wallpaper and folder
|
||||
*/
|
||||
fun getAlbumsWithWallpaperAndFolder(): Flow<List<AlbumWithWallpaperAndFolder>>
|
||||
|
||||
/**
|
||||
* Insert or update album with wallpaper and folder
|
||||
*/
|
||||
suspend fun upsertAlbumWithWallpaperAndFolder(albumWithWallpaperAndFolder: AlbumWithWallpaperAndFolder)
|
||||
|
||||
/**
|
||||
* Insert or update album and its wallpaper and folder
|
||||
*/
|
||||
suspend fun upsertAlbum(album: Album)
|
||||
|
||||
/**
|
||||
* Delete album and its wallpaper and folder
|
||||
*/
|
||||
suspend fun deleteAlbum(album: Album)
|
||||
|
||||
/**
|
||||
* Update album
|
||||
*/
|
||||
suspend fun updateAlbum(album: Album)
|
||||
|
||||
/**
|
||||
* Cascade delete album and its wallpaper and folder. Proper way to delete an AlbumWithWallpaperAndFolder
|
||||
*/
|
||||
suspend fun cascadeDeleteAlbum(album: Album)
|
||||
|
||||
/**
|
||||
* Insert or update wallpaper
|
||||
*/
|
||||
suspend fun upsertWallpaper(wallpaper: Wallpaper)
|
||||
|
||||
/**
|
||||
* Insert or update wallpaper list in one transaction
|
||||
*/
|
||||
suspend fun upsertWallpaperList(wallpapers: List<Wallpaper>)
|
||||
|
||||
/**
|
||||
* Delete wallpaper
|
||||
*/
|
||||
suspend fun deleteWallpaper(wallpaper: Wallpaper)
|
||||
|
||||
/**
|
||||
* Delete wallpaper list in one transaction
|
||||
*/
|
||||
suspend fun deleteWallpaperList(wallpapers: List<Wallpaper>)
|
||||
|
||||
/**
|
||||
* Update wallpaper
|
||||
*/
|
||||
suspend fun updateWallpaper(wallpaper: Wallpaper)
|
||||
|
||||
/**
|
||||
* Cascade delete wallpaper. Proper way to delete a single wallpaper
|
||||
*/
|
||||
suspend fun cascadeDeleteWallpaper(initialAlbumName: String)
|
||||
|
||||
/**
|
||||
* Insert or update folder
|
||||
*/
|
||||
suspend fun upsertFolder(folder: Folder)
|
||||
|
||||
/**
|
||||
* Insert or update folder list in one transaction
|
||||
*/
|
||||
suspend fun upsertFolderList(folders: List<Folder>)
|
||||
|
||||
/**
|
||||
* Delete folder
|
||||
*/
|
||||
suspend fun deleteFolder(folder: Folder)
|
||||
|
||||
/**
|
||||
* Update folder
|
||||
*/
|
||||
suspend fun updateFolder(folder: Folder)
|
||||
|
||||
/**
|
||||
* Cascade delete folder. Proper way to delete a single folder
|
||||
*/
|
||||
suspend fun cascadeDeleteFolder(initialAlbumName: String)
|
||||
|
||||
/**
|
||||
* Delete folder list in one transaction
|
||||
*/
|
||||
suspend fun deleteFolderList(folders: List<Folder>)
|
||||
}
|
||||
+40
-2
@@ -1,21 +1,59 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.domain.repository
|
||||
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Album
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface SelectedAlbumRepository {
|
||||
/**
|
||||
* Get selected album from database
|
||||
*/
|
||||
fun getSelectedAlbum(): Flow<List<SelectedAlbum>>
|
||||
|
||||
/**
|
||||
* Upsert or insert selectedAlbum to database with its wallpapers
|
||||
*/
|
||||
suspend fun upsertSelectedAlbum(selectedAlbum: SelectedAlbum)
|
||||
|
||||
/**
|
||||
* Upsert or insert album to database
|
||||
*/
|
||||
suspend fun upsertAlbum(album: Album)
|
||||
|
||||
/**
|
||||
* Upsert or insert wallpaper to database
|
||||
*/
|
||||
suspend fun updateAlbum(album: Album)
|
||||
|
||||
/**
|
||||
* Delete album from database
|
||||
*/
|
||||
suspend fun deleteAlbum(album: Album)
|
||||
|
||||
/**
|
||||
* Upsert or insert wallpaper to database
|
||||
*/
|
||||
suspend fun upsertWallpaper(wallpaper: Wallpaper)
|
||||
|
||||
/**
|
||||
* Upsert or insert list of wallpapers to database
|
||||
|
||||
*/
|
||||
suspend fun upsertWallpaperList(wallpapers: List<Wallpaper>)
|
||||
|
||||
/**
|
||||
* Delete wallpaper from database
|
||||
*/
|
||||
suspend fun deleteWallpaper(wallpaper: Wallpaper)
|
||||
|
||||
/**
|
||||
* Delete all wallpapers and folders from database
|
||||
*/
|
||||
suspend fun cascadeDeleteWallpaper(initialAlbumName: String)
|
||||
|
||||
/**
|
||||
* Delete all data from database
|
||||
*/
|
||||
suspend fun deleteAll()
|
||||
}
|
||||
+7
-1
@@ -32,6 +32,8 @@ class MainActivity : ComponentActivity() {
|
||||
private val settingsViewModel: SettingsViewModel by viewModels()
|
||||
private val wallpaperScreenViewModel: WallpaperScreenViewModel by viewModels()
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
// Show splash screen until app data is fully loaded and ready to be displayed
|
||||
val splashScreen = installSplashScreen()
|
||||
super.onCreate(savedInstanceState)
|
||||
splashScreen.setKeepOnScreenCondition {
|
||||
@@ -40,7 +42,7 @@ class MainActivity : ComponentActivity() {
|
||||
|| wallpaperScreenViewModel.shouldNotBypassSplashScreen
|
||||
}
|
||||
setContent {
|
||||
enableEdgeToEdge()
|
||||
// Refresh albums when the app is resumed
|
||||
val lifecycleEvent = rememberLifecycleEvent()
|
||||
LaunchedEffect(lifecycleEvent) {
|
||||
if (lifecycleEvent == Lifecycle.Event.ON_RESUME) {
|
||||
@@ -48,6 +50,7 @@ class MainActivity : ComponentActivity() {
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Refresh)
|
||||
}
|
||||
}
|
||||
|
||||
PaperizeTheme(settingsViewModel.state) {
|
||||
Surface(tonalElevation = 5.dp) {
|
||||
PaperizeApp(albumsViewModel, settingsViewModel, wallpaperScreenViewModel)
|
||||
@@ -57,6 +60,9 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the latest lifecycle event of the [LifecycleOwner].
|
||||
*/
|
||||
@Composable
|
||||
fun rememberLifecycleEvent(lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current): Lifecycle.Event {
|
||||
var state by remember { mutableStateOf(Lifecycle.Event.ON_ANY) }
|
||||
|
||||
+26
-36
@@ -47,9 +47,7 @@ fun PaperizeApp(
|
||||
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||
val selectedState = wallpaperScreenViewModel.state.collectAsStateWithLifecycle()
|
||||
|
||||
/**
|
||||
* React to albumState changes and change selectedAlbum's details to keep it from being stale
|
||||
*/
|
||||
// React to albumState changes and change selectedAlbum's details to keep it from being stale
|
||||
LaunchedEffect(albumState.value.albumsWithWallpapers) {
|
||||
selectedState.value.selectedAlbum?.let { selectedAlbum ->
|
||||
albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == selectedAlbum.album.initialAlbumName }
|
||||
@@ -60,9 +58,7 @@ fun PaperizeApp(
|
||||
|
||||
val navController = rememberNavController()
|
||||
|
||||
/**
|
||||
* Contact author popup with email
|
||||
*/
|
||||
// Contact author popup with email
|
||||
var toContact by rememberSaveable { mutableStateOf(false) }
|
||||
if (toContact) {
|
||||
Contact(LocalContext.current)
|
||||
@@ -167,32 +163,30 @@ fun PaperizeApp(
|
||||
) { backStackEntry ->
|
||||
val initialAlbumName = backStackEntry.arguments?.getString("initialAlbumName")
|
||||
val albumWithWallpaper = albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == initialAlbumName }
|
||||
if (initialAlbumName != null) {
|
||||
if (albumWithWallpaper != null) {
|
||||
AlbumViewScreen(
|
||||
album = albumWithWallpaper,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
onShowWallpaperView = { wallpaper ->
|
||||
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
|
||||
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
|
||||
},
|
||||
onShowFolderView = { folder, folderName, wallpapers ->
|
||||
val encodedFolder = runBlocking { encodeUri(uri = folder) }
|
||||
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
|
||||
navController.navigate("${NavScreens.FolderView.route}/$encodedFolder/$folderName/$encodedWallpapers")
|
||||
},
|
||||
onDeleteAlbum = {
|
||||
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpaper))
|
||||
navController.navigateUp()
|
||||
},
|
||||
onTitleChange = { title, originalAlbumWithWallpaper ->
|
||||
albumsViewModel.onEvent(AlbumsEvent.ChangeAlbumName(title, originalAlbumWithWallpaper))
|
||||
},
|
||||
onSelectionDeleted = {
|
||||
albumsViewModel.onEvent(AlbumsEvent.RefreshAlbums)
|
||||
}
|
||||
)
|
||||
}
|
||||
if (initialAlbumName != null && albumWithWallpaper != null) {
|
||||
AlbumViewScreen(
|
||||
album = albumWithWallpaper,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
onShowWallpaperView = { wallpaper ->
|
||||
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
|
||||
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
|
||||
},
|
||||
onShowFolderView = { folder, folderName, wallpapers ->
|
||||
val encodedFolder = runBlocking { encodeUri(uri = folder) }
|
||||
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
|
||||
navController.navigate("${NavScreens.FolderView.route}/$encodedFolder/$folderName/$encodedWallpapers")
|
||||
},
|
||||
onDeleteAlbum = {
|
||||
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpaper))
|
||||
navController.navigateUp()
|
||||
},
|
||||
onTitleChange = { title, originalAlbumWithWallpaper ->
|
||||
albumsViewModel.onEvent(AlbumsEvent.ChangeAlbumName(title, originalAlbumWithWallpaper))
|
||||
},
|
||||
onSelectionDeleted = {
|
||||
albumsViewModel.onEvent(AlbumsEvent.RefreshAlbums)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
// Navigate to the settings screen to change app settings
|
||||
@@ -200,25 +194,21 @@ fun PaperizeApp(
|
||||
route = NavScreens.Settings.route,
|
||||
enterTransition = {
|
||||
slideInHorizontally(
|
||||
// Enter by sliding in from offset +fullWidth to 0.
|
||||
initialOffsetX = { fullWidth -> fullWidth },
|
||||
)
|
||||
},
|
||||
exitTransition = {
|
||||
slideOutHorizontally(
|
||||
// Exit by sliding out from offset 0 to +fullWidth.
|
||||
targetOffsetX = { fullWidth -> fullWidth },
|
||||
)
|
||||
},
|
||||
popEnterTransition = {
|
||||
slideInHorizontally(
|
||||
// Pop Enter by sliding in from offset +fullWidth to 0.
|
||||
initialOffsetX = { fullWidth -> fullWidth },
|
||||
)
|
||||
},
|
||||
popExitTransition = {
|
||||
slideOutHorizontally(
|
||||
// Pop Exit by sliding out from offset 0 to +fullWidth.
|
||||
targetOffsetX = { fullWidth -> fullWidth },
|
||||
)
|
||||
}
|
||||
|
||||
+3
@@ -38,6 +38,9 @@ import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.components.MenuRow
|
||||
|
||||
/**
|
||||
* Animated FAB that expands to show two options: Add image and Add folder
|
||||
*/
|
||||
@Composable
|
||||
fun AddAlbumAnimatedFab(menuOptions: AddAlbumFabMenuOptions, onImageClick: () -> Unit, onFolderClick: () -> Unit) {
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
|
||||
+3
-9
@@ -3,25 +3,17 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.c
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
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.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Delete
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -34,7 +26,6 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -43,6 +34,9 @@ import androidx.compose.ui.window.Dialog
|
||||
import com.anthonyla.paperize.R
|
||||
import kotlinx.coroutines.android.awaitFrame
|
||||
|
||||
/**
|
||||
* Dialog for adding a new album.
|
||||
*/
|
||||
@Composable
|
||||
fun AddAlbumDialog(
|
||||
onDismissRequest: () -> Unit,
|
||||
|
||||
+3
@@ -5,6 +5,9 @@ import androidx.compose.material.icons.filled.Folder
|
||||
import androidx.compose.material.icons.filled.PhotoLibrary
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.components.SelectionOptions
|
||||
|
||||
/**
|
||||
* Options for the FAB menu in the Add Album screen
|
||||
*/
|
||||
data class AddAlbumFabMenuOptions (
|
||||
val imageOption: SelectionOptions = SelectionOptions("add_images", "Add Image", null, Icons.Filled.PhotoLibrary),
|
||||
val folderOption: SelectionOptions = SelectionOptions("add_folder", "Add Folder", null, Icons.Filled.Folder)
|
||||
|
||||
+3
@@ -44,6 +44,9 @@ import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.AddAlbumState
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
/**
|
||||
* Top bar for the Add Album screen
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun AddAlbumSmallTopBar(
|
||||
|
||||
+3
@@ -10,6 +10,9 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* AlertDialog to confirm deletion of images
|
||||
*/
|
||||
@Composable
|
||||
fun DeleteImagesAlertDialog(
|
||||
onDismissRequest: () -> Unit,
|
||||
|
||||
+3
-2
@@ -1,6 +1,5 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -28,7 +27,9 @@ import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
||||
import com.skydoves.landscapist.ImageOptions
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
||||
|
||||
/**
|
||||
* AlbumItem composable is a single item view for the Album list. Shows the thumbnail cover image.
|
||||
*/
|
||||
@Composable
|
||||
fun AlbumItem(
|
||||
album: Album,
|
||||
|
||||
+3
-1
@@ -47,7 +47,9 @@ import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
||||
import com.skydoves.landscapist.ImageOptions
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
||||
|
||||
/**
|
||||
* FolderItem composable is a single item of the folder list. It shows the folder's cover image,
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun FolderItem(
|
||||
|
||||
+3
-1
@@ -37,11 +37,13 @@ import androidx.core.net.toUri
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.anthonyla.paperize.R
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions.withCrossFade
|
||||
import com.skydoves.landscapist.ImageOptions
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
||||
/**
|
||||
* A composable that displays a wallpaper item. It shows the wallpaper image and a selection icon when selected
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun WallpaperItem(
|
||||
|
||||
+3
@@ -34,6 +34,9 @@ import androidx.compose.ui.window.Dialog
|
||||
import com.anthonyla.paperize.R
|
||||
import kotlinx.coroutines.android.awaitFrame
|
||||
|
||||
/**
|
||||
* Dialog for creating a new album. Input of album name is required.
|
||||
*/
|
||||
@Composable
|
||||
fun AlbumNameDialog(
|
||||
onDismissRequest: () -> Unit,
|
||||
|
||||
+3
-1
@@ -38,11 +38,13 @@ import androidx.compose.ui.unit.DpOffset
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.AddAlbumState
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.DeleteImagesAlertDialog
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album_view_screen.AlbumViewState
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
/**
|
||||
* Top bar for the album view screen
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun AlbumViewTopBar(
|
||||
|
||||
+3
@@ -10,6 +10,9 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* AlertDialog for confirmation of deleting an album
|
||||
*/
|
||||
@Composable
|
||||
fun DeleteAlbumAlertDialog(
|
||||
onDismissRequest: () -> Unit,
|
||||
|
||||
+3
@@ -17,6 +17,9 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Top bar for the folder view screen.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun FolderViewTopBar(
|
||||
|
||||
+3
-2
@@ -3,7 +3,6 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.home_screen.compon
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
@@ -33,12 +32,14 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.DpOffset
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.DeleteImagesAlertDialog
|
||||
|
||||
/**
|
||||
* Top bar for the home screen
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun HomeTopBar (
|
||||
|
||||
+3
-4
@@ -1,13 +1,9 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.components
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -20,6 +16,9 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
/**
|
||||
* A row that contains an icon, text, and an onClick listener.
|
||||
*/
|
||||
@Composable
|
||||
fun MenuRow(text: String, icon: ImageVector?, horizontalExpansion: Dp, onClick: () -> Unit) {
|
||||
Row(
|
||||
|
||||
+3
@@ -2,6 +2,9 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.com
|
||||
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
|
||||
/**
|
||||
* Data class for selection options
|
||||
*/
|
||||
data class SelectionOptions(
|
||||
val id: String = "",
|
||||
val text: String = "",
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.components
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
fun WallpaperLazyStaggeredList() {
|
||||
/*
|
||||
LazyVerticalStaggeredGrid(
|
||||
state = lazyListState,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
columns = StaggeredGridCells.Fixed(3),
|
||||
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 16.dp),
|
||||
verticalItemSpacing = 8.dp,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
content = {
|
||||
items(wallpaperState.wallpapers, key = { it.imageUri })
|
||||
{ wallpaper ->
|
||||
WallpaperItem(
|
||||
selected = selectedImageUris.contains(wallpaper.imageUri),
|
||||
selectionMode = inSelectionMode,
|
||||
image = wallpaper.imageUri.toUri(),
|
||||
onSelectionListClick = {
|
||||
inSelectionMode = true
|
||||
selectedImageUris = if (selectedImageUris.contains(wallpaper.imageUri)) {
|
||||
selectedImageUris.toMutableList().apply {
|
||||
remove(wallpaper.imageUri)
|
||||
}.toImmutableList()
|
||||
} else {
|
||||
selectedImageUris.toMutableList().apply {
|
||||
add(wallpaper.imageUri)
|
||||
}.toImmutableList()
|
||||
}
|
||||
onSelectionMode(true)
|
||||
onUpdateItemCount(selectedImageUris.size)
|
||||
onAllSelected(selectedImageUris.size >= wallpaperState.wallpapers.size)
|
||||
},
|
||||
onSelection = {
|
||||
selectedImageUris = if (selectedImageUris.contains(wallpaper.imageUri)) {
|
||||
selectedImageUris.toMutableList().apply {
|
||||
remove(wallpaper.imageUri)
|
||||
}.toImmutableList()
|
||||
} else {
|
||||
selectedImageUris.toMutableList().apply {
|
||||
add(wallpaper.imageUri)
|
||||
}.toImmutableList()
|
||||
}
|
||||
onUpdateItemCount(selectedImageUris.size)
|
||||
onAllSelected(selectedImageUris.size >= wallpaperState.wallpapers.size)
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
*/
|
||||
}
|
||||
+4
-2
@@ -33,6 +33,9 @@ import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
/**
|
||||
* Three-state selector for dark mode in settings
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
||||
@@ -99,8 +102,7 @@ fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
||||
else -> null
|
||||
}
|
||||
) },
|
||||
selected = index == selectedIndex,
|
||||
icon = { null },
|
||||
selected = index == selectedIndex
|
||||
) {
|
||||
Icon(
|
||||
contentDescription = label.first,
|
||||
|
||||
+3
@@ -17,6 +17,9 @@ import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
/**
|
||||
* Dynamic theming switch
|
||||
*/
|
||||
@Composable
|
||||
fun DynamicThemingListItem(dynamicTheming: Boolean, onDynamicThemingClick: (Boolean) -> Unit) {
|
||||
Row {
|
||||
|
||||
+3
@@ -5,6 +5,9 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
|
||||
/**
|
||||
* A composable that displays a section title for a list.
|
||||
*/
|
||||
@Composable
|
||||
fun ListSectionTitle(title: String) {
|
||||
Text(
|
||||
|
||||
+3
-1
@@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -18,6 +17,9 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
/**
|
||||
* Scrollable settings screen to wrap all settings components
|
||||
*/
|
||||
@Composable
|
||||
fun ScrollableSettings(
|
||||
settingsState: StateFlow<SettingsState>,
|
||||
|
||||
+3
-12
@@ -1,23 +1,14 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
||||
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Large top app bar for the settings screen. Replaced with [SettingsSmallTopAppBar] when scrolling down
|
||||
*/
|
||||
@Composable
|
||||
fun SettingsLargeTopAppBar(
|
||||
scroll: ScrollState,
|
||||
|
||||
+3
@@ -17,6 +17,9 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Small top app bar for settings screen to replace [SettingsLargeTopAppBar] when scrolling down
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsSmallTopAppBar(onBackClick: () -> Unit) {
|
||||
|
||||
+3
@@ -18,6 +18,9 @@ import androidx.compose.ui.unit.lerp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Title for the settings screen.
|
||||
*/
|
||||
@Composable
|
||||
fun SettingsTitle(
|
||||
largeTopAppBarHeight: Dp,
|
||||
|
||||
+6
@@ -7,12 +7,18 @@ import androidx.compose.material.icons.outlined.AddToPhotos
|
||||
import androidx.compose.material.icons.outlined.Image
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
|
||||
/**
|
||||
* Data class representing a tab item
|
||||
*/
|
||||
data class TabItem(
|
||||
val title: String,
|
||||
val filledIcon: ImageVector,
|
||||
val unfilledIcon: ImageVector,
|
||||
)
|
||||
|
||||
/**
|
||||
* List of tab items
|
||||
*/
|
||||
val tabItems = listOf(
|
||||
TabItem(
|
||||
title = "Wallpaper",
|
||||
|
||||
+13
-10
@@ -4,7 +4,6 @@ import android.app.Activity
|
||||
import android.graphics.Color.TRANSPARENT
|
||||
import android.os.Build
|
||||
import androidx.activity.SystemBarStyle
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
@@ -145,6 +144,9 @@ private val DarkColors = darkColorScheme(
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* App theming for dynamic theming when supported and dark mode.
|
||||
*/
|
||||
@Composable
|
||||
fun PaperizeTheme(
|
||||
settingsState: StateFlow<SettingsState>,
|
||||
@@ -155,7 +157,7 @@ fun PaperizeTheme(
|
||||
|
||||
val isDarkMode = isDarkMode(darkMode = state.value.darkMode)
|
||||
val isDynamicTheming = isDynamicTheming(dynamicTheming = state.value.dynamicTheming)
|
||||
|
||||
val dynamicThemingSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||
val colors = when {
|
||||
isDynamicTheming && dynamicThemingSupported && isDarkMode -> dynamicDarkColorScheme(context)
|
||||
isDynamicTheming && dynamicThemingSupported && !isDarkMode -> dynamicLightColorScheme(context)
|
||||
@@ -163,13 +165,7 @@ fun PaperizeTheme(
|
||||
else -> LightColors
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colors,
|
||||
typography = MaterialTheme.typography,
|
||||
content = content,
|
||||
shapes = MaterialTheme.shapes
|
||||
)
|
||||
|
||||
// Set the status bar color and system bar style to transparent
|
||||
val view = LocalView.current
|
||||
if (!view.isInEditMode) {
|
||||
SideEffect {
|
||||
@@ -179,8 +175,15 @@ fun PaperizeTheme(
|
||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !isDarkMode
|
||||
}
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colors,
|
||||
typography = MaterialTheme.typography,
|
||||
content = content,
|
||||
shapes = MaterialTheme.shapes
|
||||
)
|
||||
}
|
||||
val dynamicThemingSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||
|
||||
@Composable
|
||||
private fun isDarkMode(darkMode: Boolean?): Boolean =
|
||||
when(darkMode) {
|
||||
|
||||
+3
-2
@@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
@@ -49,7 +48,9 @@ fun WallpaperScreen(
|
||||
currentSelectedAlbum = selectedState.value.selectedAlbum,
|
||||
onDismiss = { openBottomSheet = false },
|
||||
onSelect = { album ->
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(album))
|
||||
if ((selectedState.value.selectedAlbum?.album?.initialAlbumName ?: "") != album.album.initialAlbumName) {
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(album))
|
||||
}
|
||||
openBottomSheet = false
|
||||
}
|
||||
)
|
||||
|
||||
+26
-3
@@ -6,21 +6,44 @@ import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.BrowseGallery
|
||||
import androidx.compose.material.icons.filled.Image
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.filled.Wallpaper
|
||||
import androidx.compose.material.icons.outlined.Add
|
||||
import androidx.compose.material.icons.outlined.BrowseGallery
|
||||
import androidx.compose.material.icons.outlined.Image
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material.icons.outlined.Wallpaper
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
|
||||
/**
|
||||
* Enum class for navigation screens in application
|
||||
*/
|
||||
sealed class NavScreens(val route: String, @StringRes val resourceId: Int, val unfilledIcon: ImageVector, val filledIcon: ImageVector) {
|
||||
/**
|
||||
* Home screen that the user lands on initially
|
||||
*/
|
||||
object Home : NavScreens("home_screen", R.string.home_screen, Icons.Outlined.Image, Icons.Filled.Image)
|
||||
|
||||
/**
|
||||
* Settings screen for the application
|
||||
*/
|
||||
object Settings : NavScreens("settings_screen", R.string.settings_screen, Icons.Outlined.Settings, Icons.Filled.Settings)
|
||||
|
||||
/**
|
||||
* Add/Edit screen for album when adding or editing
|
||||
*/
|
||||
object AddEdit : NavScreens("add_edit_screen", R.string.add_wallpaper_screen, Icons.Outlined.Add, Icons.Filled.Add)
|
||||
|
||||
/**
|
||||
* Wallpaper view screen for viewing wallpapers when clicking on a wallpaper
|
||||
*/
|
||||
object WallpaperView : NavScreens("wallpaper_view_screen", R.string.wallpaper_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
|
||||
|
||||
/**
|
||||
* Folder view screen for viewing wallpapers in a folder when clicking on a folder
|
||||
*/
|
||||
object FolderView : NavScreens("folder_view_screen", R.string.folder_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
|
||||
|
||||
/**
|
||||
* Album view screen for viewing albums when clicking on an album. Shows wallpapers and folders of the album
|
||||
*/
|
||||
object AlbumView : NavScreens("album_view_screen", R.string.album_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
}
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
plugins {
|
||||
id("com.android.application") version "8.3.1" apply false
|
||||
id("com.android.library") version "8.3.1" apply false
|
||||
|
||||
Reference in new issue
Block a user