diff --git a/.github/workflows/sonarcloud-analysis.yml b/.github/workflows/sonarcloud-analysis.yml index 525fd05..e471967 100644 --- a/.github/workflows/sonarcloud-analysis.yml +++ b/.github/workflows/sonarcloud-analysis.yml @@ -38,4 +38,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew build sonar --info \ No newline at end of file + run: ./gradlew build check sonar --info \ No newline at end of file diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/MainActivity.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/MainActivity.kt index add706b..ce50bd8 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/MainActivity.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/MainActivity.kt @@ -47,7 +47,7 @@ class MainActivity : ComponentActivity() { VariantTheme { Surface( modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background + color = MaterialTheme.colorScheme.background, ) { val serverList by serverViewModel.serverList.collectAsStateWithLifecycle() val linkList by serverLinkViewModel.displayLinkList.collectAsStateWithLifecycle() @@ -63,11 +63,12 @@ class MainActivity : ComponentActivity() { name, url, username, - password + password, ) - }) + }, + ) } } } } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/VariantApp.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/VariantApp.kt index 9a9f88a..fbf935d 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/VariantApp.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/VariantApp.kt @@ -32,21 +32,22 @@ lateinit var koin: Koin * @author Darryl L. Pierce */ class VariantApp : Application() { - override fun onCreate() { super.onCreate() VariantApp.appContext = applicationContext - koin = initKoin( - appModule = module { - single { this@VariantApp } - - }, - viewModelsModule = module { }).koin + koin = + initKoin( + appModule = + module { + single { this@VariantApp } + }, + viewModelsModule = module { }, + ).koin } companion object { lateinit var appContext: Context } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/VariantTheme.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/VariantTheme.kt index 43591e0..7bce354 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/VariantTheme.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/VariantTheme.kt @@ -41,38 +41,42 @@ import androidx.compose.ui.unit.sp @Composable fun VariantTheme( darkTheme: Boolean = isSystemInDarkTheme(), - content: @Composable () -> Unit + content: @Composable () -> Unit, ) { - val colors = if (darkTheme) { - darkColorScheme( - primary = Color(0xFFBB86FC), - secondary = Color(0xFF03DAC5), - tertiary = Color(0xFF3700B3) + val colors = + if (darkTheme) { + darkColorScheme( + primary = Color(0xFFBB86FC), + secondary = Color(0xFF03DAC5), + tertiary = Color(0xFF3700B3), + ) + } else { + lightColorScheme( + primary = Color(0xFF6200EE), + secondary = Color(0xFF03DAC5), + tertiary = Color(0xFF3700B3), + ) + } + val typography = + Typography( + bodyMedium = + TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + ), ) - } else { - lightColorScheme( - primary = Color(0xFF6200EE), - secondary = Color(0xFF03DAC5), - tertiary = Color(0xFF3700B3) + val shapes = + Shapes( + small = RoundedCornerShape(4.dp), + medium = RoundedCornerShape(4.dp), + large = RoundedCornerShape(0.dp), ) - } - val typography = Typography( - bodyMedium = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp - ) - ) - val shapes = Shapes( - small = RoundedCornerShape(4.dp), - medium = RoundedCornerShape(4.dp), - large = RoundedCornerShape(0.dp) - ) MaterialTheme( colorScheme = colors, typography = typography, shapes = shapes, - content = content + content = content, ) } diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/BottomBarItem.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/BottomBarItem.kt index 28b38f4..d75f779 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/BottomBarItem.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/BottomBarItem.kt @@ -30,16 +30,21 @@ import org.comixedproject.variant.android.R * * @author Darryl L. Pierce */ -enum class BottomBarItem(val label: Int, val icon: ImageVector, val screen: NavigationScreen) { +enum class BottomBarItem( + val label: Int, + val icon: ImageVector, + val screen: NavigationScreen, +) { ServerList(R.string.serverButtonLabel, Icons.Filled.AccountBox, NavigationScreen.Servers), ComicList( R.string.comicsButtonLabel, Icons.AutoMirrored.Filled.List, - NavigationScreen.ComicList + NavigationScreen.ComicList, ), - Settings(R.string.settingsButtonLabel, Icons.Filled.Settings, NavigationScreen.Settings); + Settings(R.string.settingsButtonLabel, Icons.Filled.Settings, NavigationScreen.Settings), + ; companion object { val all = values() } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/BottomBarView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/BottomBarView.kt index 59e04a3..e2d5c1a 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/BottomBarView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/BottomBarView.kt @@ -40,13 +40,14 @@ import org.comixedproject.variant.android.VariantTheme @Composable fun BottomBarView( currentDestination: NavDestination?, - onScreenChange: (route: String) -> Unit + onScreenChange: (route: String) -> Unit, ) { var selectedItem by remember { mutableIntStateOf(0) } NavigationBar { BottomBarItem.all.forEachIndexed { index, item -> - NavigationBarItem(selected = selectedItem == index, + NavigationBarItem( + selected = selectedItem == index, onClick = { selectedItem = index onScreenChange(item.screen.route) @@ -55,9 +56,10 @@ fun BottomBarView( icon = { Icon( imageVector = item.icon, - contentDescription = stringResource(id = item.label) + contentDescription = stringResource(id = item.label), ) - }) + }, + ) } } } @@ -68,4 +70,4 @@ fun BottomBarPreview() { VariantTheme { BottomBarView(null, onScreenChange = {}) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/HomeView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/HomeView.kt index d3a630e..66e105b 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/HomeView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/HomeView.kt @@ -63,7 +63,7 @@ fun HomeView( serverViewModel: ServerViewModel, linkList: List, serverLinkViewModel: ServerLinkViewModel, - onSaveServer: (Long?, String, String, String, String) -> Unit + onSaveServer: (Long?, String, String, String, String) -> Unit, ) { val navController = rememberNavController() @@ -71,36 +71,43 @@ fun HomeView( topBar = { TopAppBar( navigationIcon = { - Icon(imageVector = Icons.Filled.Menu, contentDescription = "Menu", - modifier = Modifier.clickable { }) + Icon( + imageVector = Icons.Filled.Menu, + contentDescription = "Menu", + modifier = Modifier.clickable { }, + ) }, title = { var title = stringResource(id = R.string.appName) Text(title) }, - colors = TopAppBarDefaults.topAppBarColors( - containerColor = colorScheme.primaryContainer, - titleContentColor = colorScheme.primary - ) + colors = + TopAppBarDefaults.topAppBarColors( + containerColor = colorScheme.primaryContainer, + titleContentColor = colorScheme.primary, + ), ) }, bottomBar = { - BottomBarView(currentDestination = navController.currentBackStackEntryAsState().value?.destination, - onScreenChange = { route -> navController.navigate(route) }) + BottomBarView( + currentDestination = navController.currentBackStackEntryAsState().value?.destination, + onScreenChange = { route -> navController.navigate(route) }, + ) }, ) { padding -> Column( - modifier = Modifier - .padding(padding) - .fillMaxSize() + modifier = + Modifier + .padding(padding) + .fillMaxSize(), ) { NavHost( modifier = Modifier, navController = navController, - startDestination = NavigationScreen.Servers.route + startDestination = NavigationScreen.Servers.route, ) { composable( - route = NavigationScreen.Servers.route + route = NavigationScreen.Servers.route, ) { ServerManagementView( servers = serverList, @@ -110,34 +117,37 @@ fun HomeView( serverLinkViewModel.directory = server.url navController.navigate("servers?serverId=${server.serverId}") }, - onDeleteServer = { } + onDeleteServer = { }, ) } composable( route = NavigationScreen.BrowseServer.route, - arguments = NavigationScreen.BrowseServer.navArguments + arguments = NavigationScreen.BrowseServer.navArguments, ) { entry -> val serverId = entry.arguments?.getLong(NAVARG_SERVER_ID) - Logger.d(TAG, "serverId=${serverId} directory=${serverLinkViewModel.directory}") + Logger.d(TAG, "serverId=$serverId directory=${serverLinkViewModel.directory}") val currentServer = serverList.firstOrNull { server -> server.serverId == serverId } if (currentServer != null) { BrowseServerView( server = currentServer, - serverLinks = linkList.filter { link -> link.serverId == currentServer.serverId } - .filter { link -> link.directory == serverLinkViewModel.directory } - .toList(), + serverLinks = + linkList + .filter { link -> link.serverId == currentServer.serverId } + .filter { link -> link.directory == serverLinkViewModel.directory } + .toList(), serverLinkViewModel.directory, onLoadDirectory = { target, selectedLink -> serverLinkViewModel.loadServerDirectory( target, selectedLink.href, - false + false, ) serverLinkViewModel.directory = selectedLink.href navController.navigate("servers?serverId=${target.serverId}") - }) + }, + ) } } composable(route = NavigationScreen.ComicList.route) { @@ -161,12 +171,12 @@ fun HomeSPreview() { Server(null, "Server 2", "", "", ""), Server(null, "Server 3", "", "", ""), Server(null, "Server 4", "", "", ""), - Server(null, "Server 5", "", "", "") + Server(null, "Server 5", "", "", ""), ), ServerViewModel(), emptyList(), ServerLinkViewModel(), - onSaveServer = { _, _, _, _, _ -> } + onSaveServer = { _, _, _, _, _ -> }, ) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/NavigationScreen.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/NavigationScreen.kt index 5e0902d..9139fe9 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/NavigationScreen.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/NavigationScreen.kt @@ -29,19 +29,24 @@ const val NAVARG_SERVER_ID = "serverId" * * @author Darryl L. Pierce */ -enum class NavigationScreen(val route: String, val navArguments: List) { +enum class NavigationScreen( + val route: String, + val navArguments: List, +) { ComicList("comics", emptyList()), Servers("servers", emptyList()), BrowseServer( - "servers?serverId={serverId}", listOf( + "servers?serverId={serverId}", + listOf( navArgument(NAVARG_SERVER_ID) { type = NavType.LongType - } - )), - Settings("settings", emptyList()); + }, + ), + ), + Settings("settings", emptyList()), + ; companion object { val all = values() } } - diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/SwipeBoxView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/SwipeBoxView.kt index e348875..455a0d8 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/SwipeBoxView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/SwipeBoxView.kt @@ -50,7 +50,7 @@ fun SwipeBoxView( modifier: Modifier = Modifier, onDelete: () -> Unit, onEdit: () -> Unit, - content: @Composable () -> Unit + content: @Composable () -> Unit, ) { val swipeState = rememberSwipeToDismissBoxState() @@ -85,16 +85,18 @@ fun SwipeBoxView( backgroundContent = { Box( contentAlignment = alignment, - modifier = Modifier - .fillMaxSize() - .background(color) + modifier = + Modifier + .fillMaxSize() + .background(color), ) { Icon( modifier = Modifier.minimumInteractiveComponentSize(), - imageVector = icon, contentDescription = null + imageVector = icon, + contentDescription = null, ) } - } + }, ) { content() } @@ -114,4 +116,4 @@ fun SwipeBoxView( SwipeToDismissBoxValue.Settled -> { } } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/links/ServerLinkList.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/links/ServerLinkList.kt index 1765b8e..3d0eb39 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/links/ServerLinkList.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/links/ServerLinkList.kt @@ -38,7 +38,7 @@ fun ServerLinkList( server: Server, serverLinks: List, onLoadDirectory: (Server, ServerLink) -> Unit, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { LazyColumn(modifier) { items(serverLinks) { link -> @@ -52,13 +52,14 @@ fun ServerLinkList( fun ServerLinkListPreview() { VariantTheme { ServerLinkList( - server = Server( - 1L, - "My Server", - "http://www.comixedproject.org:7171/opds", - "reader@comixedproject.org", - "my!password" - ), + server = + Server( + 1L, + "My Server", + "http://www.comixedproject.org:7171/opds", + "reader@comixedproject.org", + "my!password", + ), listOf( ServerLink( 1L, @@ -67,18 +68,19 @@ fun ServerLinkListPreview() { "", "First Link", "", - ServerLinkType.NAVIGATION - ), ServerLink( + ServerLinkType.NAVIGATION, + ), + ServerLink( 2L, 2L, "", "", "Second Link", "", - ServerLinkType.PUBLICATION - ) + ServerLinkType.PUBLICATION, + ), ), - onLoadDirectory = { server, directory -> } + onLoadDirectory = { server, directory -> }, ) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/links/ServerLinkListItem.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/links/ServerLinkListItem.kt index 18c8487..26ae30b 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/links/ServerLinkListItem.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/links/ServerLinkListItem.kt @@ -36,25 +36,38 @@ import org.comixedproject.variant.shared.model.server.ServerLinkType */ @Composable fun ServerLinkListItem( - server: Server, link: ServerLink, onLoadDirectory: (Server, ServerLink) -> Unit + server: Server, + link: ServerLink, + onLoadDirectory: (Server, ServerLink) -> Unit, ) { ListItem( headlineContent = { Text(link.title!!) }, - modifier = Modifier.clickable { onLoadDirectory(server, link) }) + modifier = Modifier.clickable { onLoadDirectory(server, link) }, + ) } @Preview @Composable fun ServerLinkListItemPreview() { VariantTheme { - ServerLinkListItem(Server( - 1L, - "My Server", - "http://www.comixedproject.org:7171/opds", - "reader@comixedproject.org", - "my!password" - ), ServerLink( - 1L, 1L, "", "", "First Link", "", ServerLinkType.NAVIGATION - ), onLoadDirectory = { _, _ -> }) + ServerLinkListItem( + Server( + 1L, + "My Server", + "http://www.comixedproject.org:7171/opds", + "reader@comixedproject.org", + "my!password", + ), + ServerLink( + 1L, + 1L, + "", + "", + "First Link", + "", + ServerLinkType.NAVIGATION, + ), + onLoadDirectory = { _, _ -> }, + ) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/BrowseServerView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/BrowseServerView.kt index b6f781c..1b1fbd2 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/BrowseServerView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/BrowseServerView.kt @@ -40,12 +40,12 @@ fun BrowseServerView( server: Server, serverLinks: List, directory: String, - onLoadDirectory: (Server, ServerLink) -> Unit + onLoadDirectory: (Server, ServerLink) -> Unit, ) { ServerLinkList( server, serverLinks, - onLoadDirectory + onLoadDirectory, ) Spacer(modifier = Modifier) } @@ -63,7 +63,7 @@ fun BrowseServerPreview() { "My Server", "http://www.comixedproject.org:7171/opds", "reader@comixedproject.org", - "my!password" + "my!password", ), mutableListOf( ServerLink( @@ -72,7 +72,8 @@ fun BrowseServerPreview() { DIRECTORY, "/opds/link1", "First Entry", - "", ServerLinkType.NAVIGATION + "", + ServerLinkType.NAVIGATION, ), ServerLink( 101L, @@ -80,7 +81,8 @@ fun BrowseServerPreview() { DIRECTORY, "/opds/link1", "Second Entry", - "", ServerLinkType.NAVIGATION + "", + ServerLinkType.NAVIGATION, ), ServerLink( 102L, @@ -88,7 +90,8 @@ fun BrowseServerPreview() { DIRECTORY, "/opds/link1", "Third Entry", - "", ServerLinkType.NAVIGATION + "", + ServerLinkType.NAVIGATION, ), ServerLink( 103L, @@ -96,7 +99,8 @@ fun BrowseServerPreview() { DIRECTORY, "/opds/link1", "Fourth Entry", - "", ServerLinkType.NAVIGATION + "", + ServerLinkType.NAVIGATION, ), ServerLink( 104L, @@ -104,12 +108,12 @@ fun BrowseServerPreview() { DIRECTORY, "/opds/link1", "Fifth Entry", - "", ServerLinkType.NAVIGATION - ) + "", + ServerLinkType.NAVIGATION, + ), ), - DIRECTORY, - onLoadDirectory = { _, _ -> } + onLoadDirectory = { _, _ -> }, ) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerDetailView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerDetailView.kt index 1eae6da..fbe8fd2 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerDetailView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerDetailView.kt @@ -39,13 +39,14 @@ fun ServerDetailView(server: Server) { fun ServerDetailPreview() { VariantTheme { ServerDetailView( - server = Server( - 1L, - "Server 1", - "http://www.comixedproject.org:7171/opds", - "reader@comixedprojecvt.org", - "password" - ) + server = + Server( + 1L, + "Server 1", + "http://www.comixedproject.org:7171/opds", + "reader@comixedprojecvt.org", + "password", + ), ) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerEditView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerEditView.kt index 1b73ed3..748930e 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerEditView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerEditView.kt @@ -52,7 +52,7 @@ import org.comixedproject.variant.shared.model.server.Server fun ServerEditView( server: Server, onSave: (Long?, String, String, String, String) -> Unit, - onCancel: () -> Unit + onCancel: () -> Unit, ) { val serverId by remember { mutableStateOf(server.serverId) } var name by remember { mutableStateOf(server.name) } @@ -65,38 +65,40 @@ fun ServerEditView( Button(onClick = { onSave(serverId, name, url, username, password) }) { Icon( imageVector = Icons.Filled.Check, - contentDescription = stringResource(id = R.string.saveButtonLabel) + contentDescription = stringResource(id = R.string.saveButtonLabel), ) } - }) { padding -> + }, + ) { padding -> Column( - modifier = Modifier - .padding(32.dp) - .verticalScroll(rememberScrollState()) + modifier = + Modifier + .padding(32.dp) + .verticalScroll(rememberScrollState()), ) { TextField( value = name, placeholder = { Text(text = stringResource(id = R.string.serverNamePlaceholder)) }, onValueChange = { name = it }, - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), ) TextField( value = url, placeholder = { Text(text = stringResource(id = R.string.serverUrlPlaceholder)) }, onValueChange = { url = it }, - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), ) TextField( value = username, placeholder = { Text(text = stringResource(id = R.string.useramePlaceholder)) }, onValueChange = { username = it }, - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), ) TextField( value = password, placeholder = { Text(text = stringResource(id = R.string.passwordPlaceholder)) }, onValueChange = { password = it }, - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), ) } } @@ -107,13 +109,16 @@ fun ServerEditView( fun ServerEditPreview_Create() { VariantTheme { ServerEditView( - server = Server( - null, - "", - "", - "", - "" - ), onSave = { _, _, _, _, _ -> }, onCancel = {} + server = + Server( + null, + "", + "", + "", + "", + ), + onSave = { _, _, _, _, _ -> }, + onCancel = {}, ) } } @@ -123,13 +128,16 @@ fun ServerEditPreview_Create() { fun ServerEditPreview_Edit() { VariantTheme { ServerEditView( - server = Server( - 1L, - "My Server", - "http://www.comixedproject.org:7171/opds", - "reader@comixedproject.org", - "my!password" - ), onSave = { _, _, _, _, _ -> }, onCancel = {} + server = + Server( + 1L, + "My Server", + "http://www.comixedproject.org:7171/opds", + "reader@comixedproject.org", + "my!password", + ), + onSave = { _, _, _, _, _ -> }, + onCancel = {}, ) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerListItemView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerListItemView.kt index 60c27b7..1ed148a 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerListItemView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerListItemView.kt @@ -40,7 +40,7 @@ fun ServerListItemView( server: Server, onServerClicked: (Server) -> Unit, onEditServer: (Server) -> Unit, - onDeleteServer: (Server) -> Unit + onDeleteServer: (Server) -> Unit, ) { ListItem( headlineContent = { Text(server.name) }, @@ -48,31 +48,32 @@ fun ServerListItemView( leadingContent = { Icon( imageVector = Icons.Filled.AccountBox, - contentDescription = server.name + contentDescription = server.name, ) }, - modifier = Modifier.clickable { - onServerClicked(server) - } + modifier = + Modifier.clickable { + onServerClicked(server) + }, ) } - @Preview @Composable fun ServerListItemPreview() { VariantTheme { ServerListItemView( - server = Server( - 1L, - "Server 1", - "http://www.comixedproject.org:7171/opds", - "reader@comixedprojecvt.org", - "password" - ), + server = + Server( + 1L, + "Server 1", + "http://www.comixedproject.org:7171/opds", + "reader@comixedprojecvt.org", + "password", + ), onServerClicked = {}, onEditServer = {}, - onDeleteServer = {} + onDeleteServer = {}, ) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerListView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerListView.kt index 7e6c9de..a762b82 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerListView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerListView.kt @@ -51,13 +51,13 @@ fun ServerListView( onCreateServer: () -> Unit, onEditServer: (Server) -> Unit, onDeleteServer: (Server) -> Unit, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { Scaffold(floatingActionButton = { Button(onClick = onCreateServer) { Icon( imageVector = Icons.Filled.Add, - contentDescription = stringResource(id = R.string.serverAddButton) + contentDescription = stringResource(id = R.string.serverAddButton), ) } }) { padding -> @@ -66,13 +66,13 @@ fun ServerListView( SwipeBoxView( onDelete = { onDeleteServer(server) }, onEdit = { onEditServer(server) }, - modifier = Modifier.animateItemPlacement() + modifier = Modifier.animateItemPlacement(), ) { ServerListItemView( server, onServerClicked = onBrowseServer, onEditServer = onEditServer, - onDeleteServer = onDeleteServer + onDeleteServer = onDeleteServer, ) } } @@ -80,43 +80,52 @@ fun ServerListView( } } - @Preview @Composable fun ServerListPreview() { VariantTheme { - ServerListView(mutableListOf( - Server( - 1L, - "Server 1", - "http://www.comixedproject.org:7171/opds", - "reader@comixedprojecvt.org", - "password" - ), Server( - 2L, - "Server 2", - "http://www.comixedproject.org:7171/opds", - "reader@comixedprojecvt.org", - "password" - ), Server( - 3L, - "Server 3", - "http://www.comixedproject.org:7171/opds", - "reader@comixedprojecvt.org", - "password" - ), Server( - 4L, - "Server 4", - "http://www.comixedproject.org:7171/opds", - "reader@comixedprojecvt.org", - "password" - ), Server( - 5L, - "Server 5", - "http://www.comixedproject.org:7171/opds", - "reader@comixedprojecvt.org", - "password" - ) - ), onCreateServer = {}, onBrowseServer = {}, onEditServer = {}, onDeleteServer = {}) + ServerListView( + mutableListOf( + Server( + 1L, + "Server 1", + "http://www.comixedproject.org:7171/opds", + "reader@comixedprojecvt.org", + "password", + ), + Server( + 2L, + "Server 2", + "http://www.comixedproject.org:7171/opds", + "reader@comixedprojecvt.org", + "password", + ), + Server( + 3L, + "Server 3", + "http://www.comixedproject.org:7171/opds", + "reader@comixedprojecvt.org", + "password", + ), + Server( + 4L, + "Server 4", + "http://www.comixedproject.org:7171/opds", + "reader@comixedprojecvt.org", + "password", + ), + Server( + 5L, + "Server 5", + "http://www.comixedproject.org:7171/opds", + "reader@comixedprojecvt.org", + "password", + ), + ), + onCreateServer = {}, + onBrowseServer = {}, + onEditServer = {}, + onDeleteServer = {}, + ) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerManagementView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerManagementView.kt index ea54b59..46807ec 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerManagementView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/ui/server/ServerManagementView.kt @@ -39,7 +39,7 @@ fun ServerManagementView( servers: List, onSaveServer: (Long?, String, String, String, String) -> Unit, onBrowseServer: (Server) -> Unit, - onDeleteServer: (Server) -> Unit + onDeleteServer: (Server) -> Unit, ) { val navigator = rememberListDetailPaneScaffoldNavigator() @@ -56,17 +56,17 @@ fun ServerManagementView( onCreateServer = { navigator.navigateTo( ListDetailPaneScaffoldRole.Extra, - Server(null, "", "", "", "") + Server(null, "", "", "", ""), ) }, onBrowseServer = onBrowseServer, onEditServer = { server -> navigator.navigateTo( ListDetailPaneScaffoldRole.Extra, - server + server, ) }, - onDeleteServer = onDeleteServer + onDeleteServer = onDeleteServer, ) }, detailPane = { @@ -82,9 +82,11 @@ fun ServerManagementView( onSaveServer(serverId, name, url, username, password) navigator.navigateBack() }, - onCancel = { navigator.navigateBack() }) + onCancel = { navigator.navigateBack() }, + ) } - }) + }, + ) } @Preview @@ -98,36 +100,40 @@ fun ServerManagementPreview() { "Server 1", "http://www.comixedproject.org:7171/opds", "reader@comixedprojecvt.org", - "password" - ), Server( + "password", + ), + Server( 2L, "Server 2", "http://www.comixedproject.org:7171/opds", "reader@comixedprojecvt.org", - "password" - ), Server( + "password", + ), + Server( 3L, "Server 3", "http://www.comixedproject.org:7171/opds", "reader@comixedprojecvt.org", - "password" - ), Server( + "password", + ), + Server( 4L, "Server 4", "http://www.comixedproject.org:7171/opds", "reader@comixedprojecvt.org", - "password" - ), Server( + "password", + ), + Server( 5L, "Server 5", "http://www.comixedproject.org:7171/opds", "reader@comixedprojecvt.org", - "password" - ) + "password", + ), ), onSaveServer = { _, _, _, _, _ -> }, onBrowseServer = {}, - onDeleteServer = {} + onDeleteServer = {}, ) } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/viewmodel/ServerLinkViewModel.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/viewmodel/ServerLinkViewModel.kt index 38fef31..d96cfdc 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/viewmodel/ServerLinkViewModel.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/viewmodel/ServerLinkViewModel.kt @@ -33,52 +33,61 @@ import org.comixedproject.variant.shared.platform.Logger import org.readium.r2.opds.OPDS1Parser import org.readium.r2.shared.util.http.DefaultHttpClient +private const val TAG = "LinkViewModel" + /** * ServerLinkViewModel provides a view model for the links currently displayed for a server. * * @author Darryl L. Pierce */ class ServerLinkViewModel : ViewModel() { - val TAG = "LinkViewModel" - private val serverLinkRespository: ServerLinkRepository = koin.get() private val _displayLinksFlow: MutableStateFlow> by lazy { MutableStateFlow( - serverLinkRespository.serverLinks + serverLinkRespository.serverLinks, ) } val displayLinkList = _displayLinksFlow.asStateFlow() var directory: String = "" - fun loadServerDirectory(server: Server, url: String, reload: Boolean) { + fun loadServerDirectory( + server: Server, + url: String, + reload: Boolean, + ) { viewModelScope.launch { doLoadServerDirectory(server, url, reload) } } - suspend fun doLoadServerDirectory(server: Server, url: String, reload: Boolean) { + suspend fun doLoadServerDirectory( + server: Server, + url: String, + reload: Boolean, + ) { Logger.d( TAG, - "Loading url: server=${server.name} url=${url} reload=${reload}" - ) - val credentials = Base64.encodeToString( - "${server.username}:${server.password}".toByteArray(), - Base64.DEFAULT + "Loading url: server=${server.name} url=$url reload=$reload", ) + val credentials = + Base64.encodeToString( + "${server.username}:${server.password}".toByteArray(), + Base64.DEFAULT, + ) val headers = HashMap() - headers.put("Authorization", "Basic ${credentials}") - val httpClient = DefaultHttpClient( - userAgent = "CX-Variant", - additionalHeaders = headers - ) + headers.put("Authorization", "Basic $credentials") + val httpClient = + DefaultHttpClient( + userAgent = "CX-Variant", + additionalHeaders = headers, + ) val parser = OPDS1Parser.parseUrlString(url, httpClient) val feed = parser.getOrNull()?.feed if (feed == null) { Logger.d(TAG, "No feed elements retrieved") } else { - val links: MutableList = mutableListOf() if (!feed.navigation.isEmpty()) { feed.navigation.forEach { link -> @@ -90,17 +99,20 @@ class ServerLinkViewModel : ViewModel() { "", link.title ?: link.href, link.href, - ServerLinkType.NAVIGATION - ) + ServerLinkType.NAVIGATION, + ), ) } } feed.publications.forEach { publication -> val identifier = publication.metadata.identifier ?: "" val title = publication.metadata.title - val link = publication.links.filter { link -> - (link.type ?: "").startsWith("application/") - }.firstOrNull()?.href ?: "" + val link = + publication.links + .filter { link -> + (link.type ?: "").startsWith("application/") + }.firstOrNull() + ?.href ?: "" links.add( ServerLink( @@ -110,8 +122,8 @@ class ServerLinkViewModel : ViewModel() { identifier, title, link, - ServerLinkType.PUBLICATION - ) + ServerLinkType.PUBLICATION, + ), ) } serverLinkRespository.saveLinksForServer(server, url, links) @@ -120,4 +132,4 @@ class ServerLinkViewModel : ViewModel() { } } } -} \ No newline at end of file +} diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/viewmodel/ServerViewModel.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/viewmodel/ServerViewModel.kt index d38b19c..9df0392 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/viewmodel/ServerViewModel.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/viewmodel/ServerViewModel.kt @@ -28,18 +28,18 @@ import org.comixedproject.variant.shared.data.ServerRepository import org.comixedproject.variant.shared.model.server.Server import org.comixedproject.variant.shared.platform.Logger +private val TAG = "ServerViewModel" + /** * ServerViewModel provides a view model for the server list. * * @author Darryl L. Pierce */ -class ServerViewModel() : ViewModel() { - val TAG = "ServerViewModel" - +class ServerViewModel : ViewModel() { private val serverRespository: ServerRepository = koin.get() private val _serversFlow: MutableStateFlow> by lazy { MutableStateFlow( - serverRespository.servers + serverRespository.servers, ) } val serverList = _serversFlow.asStateFlow() @@ -49,7 +49,7 @@ class ServerViewModel() : ViewModel() { name: String, url: String, username: String, - password: String + password: String, ) { viewModelScope.launch { doCreateServer(serverId, name, url, username, password) @@ -61,11 +61,11 @@ class ServerViewModel() : ViewModel() { name: String, url: String, username: String, - password: String + password: String, ) { Logger.d( TAG, - "Saving server: serverId=${serverId} name=${name} url=${url} username=${username} password=${password}" + "Saving server: serverId=$serverId name=$name url=$url username=$username password=$password", ) val server = Server(serverId, name, url, username, password) @@ -73,4 +73,4 @@ class ServerViewModel() : ViewModel() { serverRespository.saveServer(server) _serversFlow.emit(serverRespository.servers) } -} \ No newline at end of file +} diff --git a/build.gradle.kts b/build.gradle.kts index 362c121..caec3e6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,7 @@ plugins { alias(libs.plugins.sqldelight).apply(false) alias(libs.plugins.sonarqube) + alias(libs.plugins.kotlinter) } sonar { @@ -15,4 +16,10 @@ sonar { property("sonar.host.url", "https://sonarcloud.io") property("sonar.gradle.skipCompile", true) } +} + +kotlinter { + failBuildWhenCannotAutoFormat = false + ignoreFailures = false + reporters = arrayOf("checkstyle", "plain") } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7cb45bf..c892aec 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,6 +18,7 @@ sqldelight-plugin = "2.0.2" ktor = "2.3.12" korio = "4.0.10" readium = "2.4.1" +kotlinter-plugin = "4.4.1" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -76,6 +77,7 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } sonarqube = { id = "org.sonarqube", version.ref = "sonarqube-plugin" } sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight-plugin" } +kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter-plugin" } [bundles] androidx = ["androidx-activity-compose", "androidx-core-ktx", "androidx-lifecycle-runtime-compose", "androidx-lifecycle-runtime-ktx", "koin-android", "koin-androidx-compose"] diff --git a/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/IDGenerator.android.kt b/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/IDGenerator.android.kt deleted file mode 100644 index b2fe5d8..0000000 --- a/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/IDGenerator.android.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Variant - A digital comic book reading application for the iPad and Android tablets. - * Copyright (C) 2024, The ComiXed Project - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -package org.comixedproject.variant.shared - -import java.util.UUID - -actual class IDGenerator actual constructor() { - private val value: UUID = UUID.randomUUID() - actual override fun toString() = value.toString() -} diff --git a/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/KoinAndroid.kt b/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/KoinAndroid.kt index 3f96212..0c72c63 100644 --- a/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/KoinAndroid.kt +++ b/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/KoinAndroid.kt @@ -23,8 +23,9 @@ import app.cash.sqldelight.driver.android.AndroidSqliteDriver import org.comixedproject.variant.VariantDb import org.koin.dsl.module -actual val platformModule = module { - single { - AndroidSqliteDriver(VariantDb.Schema, get(), "VariantDb") +actual val platformModule = + module { + single { + AndroidSqliteDriver(VariantDb.Schema, get(), "VariantDb") + } } -} \ No newline at end of file diff --git a/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.android.kt b/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.android.kt index ad127c7..2cd8675 100644 --- a/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.android.kt +++ b/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.android.kt @@ -20,4 +20,4 @@ package org.comixedproject.variant.shared.model import androidx.lifecycle.ViewModel -actual abstract class BaseViewModel : ViewModel() \ No newline at end of file +actual abstract class BaseViewModel : ViewModel() diff --git a/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/platform/Logger.android.kt b/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/platform/Logger.android.kt index a312ceb..659e4c5 100644 --- a/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/platform/Logger.android.kt +++ b/shared/src/androidMain/kotlin/org/comixedproject/variant/shared/platform/Logger.android.kt @@ -21,15 +21,24 @@ package org.comixedproject.variant.shared.platform import android.util.Log internal actual class Log { - actual fun debug(tag: String, message: String) { + actual fun debug( + tag: String, + message: String, + ) { Log.d(tag, message) } - actual fun warn(tag: String, message: String) { + actual fun warn( + tag: String, + message: String, + ) { Log.w(tag, message) } - actual fun error(tag: String, message: String) { + actual fun error( + tag: String, + message: String, + ) { Log.e(tag, message) } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/IDGenerator.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/IDGenerator.kt deleted file mode 100644 index b94a905..0000000 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/IDGenerator.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Variant - A digital comic book reading application for the iPad and Android tablets. - * Copyright (C) 2024, The ComiXed Project - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -package org.comixedproject.variant.shared - -expect class IDGenerator() { - override fun toString(): String -} \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/KoinCommon.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/KoinCommon.kt index 475e5fc..09f4f44 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/KoinCommon.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/KoinCommon.kt @@ -27,18 +27,20 @@ import org.koin.core.module.Module import org.koin.dsl.module object Modules { - val core = module { - factory { DatabaseHelper(get()) } - } - - val repositories = module { - factory { - ServerRepository(get()) + val core = + module { + factory { DatabaseHelper(get()) } } - factory { - ServerLinkRepository(get()) + + val repositories = + module { + factory { + ServerRepository(get()) + } + factory { + ServerLinkRepository(get()) + } } - } val viewModels = module { } } @@ -50,12 +52,13 @@ fun initKoin( coreModule: Module = Modules.core, repositoriesModule: Module = Modules.repositories, viewModelsModule: Module = Modules.viewModels, -): KoinApplication = startKoin { - modules( - appModule, - coreModule, - repositoriesModule, - viewModelsModule, - platformModule - ) -} +): KoinApplication = + startKoin { + modules( + appModule, + coreModule, + repositoriesModule, + viewModelsModule, + platformModule, + ) + } diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/Values.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/Values.kt index fa28172..9a1d2df 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/Values.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/Values.kt @@ -19,4 +19,4 @@ package org.comixedproject.variant.shared public const val X_APP_NAME = "X-App-Name" -public const val APP_NAME = "Variant" \ No newline at end of file +public const val APP_NAME = "Variant" diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/DatabaseHelper.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/DatabaseHelper.kt index 52848ee..1168d6e 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/DatabaseHelper.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/DatabaseHelper.kt @@ -25,26 +25,31 @@ import org.comixedproject.variant.db.ServersDb import org.comixedproject.variant.shared.model.server.Server import org.comixedproject.variant.shared.model.server.ServerLink -class DatabaseHelper(sqlDriver: SqlDriver) { +class DatabaseHelper( + sqlDriver: SqlDriver, +) { private val database: VariantDb = VariantDb(sqlDriver) fun loadServers(): List = database.tableQueries.loadAllServers().executeAsList() - fun createServer(name: String, url: String, username: String, password: String) { - return database.tableQueries.createServer( - name, - url, - username, - password - ) - } + fun createServer( + name: String, + url: String, + username: String, + password: String, + ) = database.tableQueries.createServer( + name, + url, + username, + password, + ) fun updateServer( serverId: Long, name: String, url: String, username: String, - password: String + password: String, ) { database.tableQueries.updateServer(name, url, username, password, serverId) } @@ -53,23 +58,27 @@ class DatabaseHelper(sqlDriver: SqlDriver) { database.tableQueries.deleteServer(serverId) } - fun loadAllLinks(): List = - database.tableQueries.loadAllLinks().executeAsList() + fun loadAllLinks(): List = database.tableQueries.loadAllLinks().executeAsList() - fun loadLinks(serverId: Long, directory: String): List = - database.tableQueries.loadLinksForParent(serverId, directory) + fun loadLinks( + serverId: Long, + directory: String, + ): List = + database.tableQueries + .loadLinksForParent(serverId, directory) .executeAsList() fun saveLinksForServer( server: Server, directory: String, - serverLinks: List + serverLinks: List, ) { val incomingPaths = serverLinks.map { it.href } val serverId = server.serverId!! val existingLinks = database.tableQueries.loadLinksForParent(serverId, directory).executeAsList() - existingLinks.filter { link -> !incomingPaths.contains(link.href) } + existingLinks + .filter { link -> !incomingPaths.contains(link.href) } .forEach { link -> database.tableQueries.deleteExistingLink(link.serverLinkId) } val existingPaths = existingLinks.map { it.href } serverLinks.filter { !existingPaths.contains(it.href) }.forEach { link -> @@ -79,8 +88,8 @@ class DatabaseHelper(sqlDriver: SqlDriver) { link.identifier, link.title, link.href, - link.linkType.name + link.linkType.name, ) } } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/FeedAPI.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/FeedAPI.kt index 3a09ec9..811e57e 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/FeedAPI.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/FeedAPI.kt @@ -38,28 +38,36 @@ private const val TAG = "FeedAPI" @ThreadLocal public object FeedAPI { - private val nonStrictJson = Json { isLenient = true; ignoreUnknownKeys = true } + private val nonStrictJson = + Json { + isLenient = true + ignoreUnknownKeys = true + } - public suspend fun loadDirectoryOnServer(server: Server, url: String): HttpResponse { - val client = HttpClient { - install(Logging) { - logger = HttpClientLogger - level = LogLevel.HEADERS - } + public suspend fun loadDirectoryOnServer( + server: Server, + url: String, + ): HttpResponse { + val client = + HttpClient { + install(Logging) { + logger = HttpClientLogger + level = LogLevel.HEADERS + } - install(Auth) { - basic { - credentials { - BasicAuthCredentials(username = server.username, password = server.password) + install(Auth) { + basic { + credentials { + BasicAuthCredentials(username = server.username, password = server.password) + } } } } - } - Logger.d(TAG, "Loading directory on server: url=${url.toString()}") + Logger.d(TAG, "Loading directory on server: url=$url") return client.get(url.toString()) { header(X_APP_NAME, APP_NAME) header("accept", "application/xml") } } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/HttpClientLogger.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/HttpClientLogger.kt index 5a65378..68444d8 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/HttpClientLogger.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/HttpClientLogger.kt @@ -26,4 +26,4 @@ public object HttpClientLogger : io.ktor.client.plugins.logging.Logger { override fun log(message: String) { Logger.d(TAG, message) } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/OpdsFeedData.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/OpdsFeedData.kt index 1e3483a..14c99ff 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/OpdsFeedData.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/OpdsFeedData.kt @@ -29,7 +29,7 @@ public class OpdsFeedData { server: Server, directory: String, onSuccess: (Any) -> Unit, - onFailure: (Exception) -> Unit + onFailure: (Exception) -> Unit, ) { try { Logger.d(TAG, "Loading directory content: server=${server.name} directory=$directory") @@ -42,9 +42,9 @@ public class OpdsFeedData { Logger.e(TAG, "Failed to load directory contents: $error") coroutineScope { { - onFailure(error); + onFailure(error) } } } } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/ServerLinkRepository.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/ServerLinkRepository.kt index 9bd9ae9..acd1ffe 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/ServerLinkRepository.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/ServerLinkRepository.kt @@ -28,25 +28,28 @@ import org.comixedproject.variant.shared.model.server.ServerLinkType * * @author Darryl L. Pierce */ -class ServerLinkRepository(private val databaseHelper: DatabaseHelper) { +class ServerLinkRepository( + private val databaseHelper: DatabaseHelper, +) { val serverLinks: List get() = databaseHelper.loadAllLinks().map(ServerLinksDb::map) fun saveLinksForServer( server: Server, directory: String, - serverLinks: List + serverLinks: List, ) { - databaseHelper.saveLinksForServer(server, directory, serverLinks); + databaseHelper.saveLinksForServer(server, directory, serverLinks) } } -fun ServerLinksDb.map() = ServerLink( - serverLinkId = this.serverLinkId, - serverId = this.serverId, - directory = this.directory, - identifier = this.identifier, - title = this.title, - href = this.href, - linkType = ServerLinkType.valueOf(this.linkType) -) +fun ServerLinksDb.map() = + ServerLink( + serverLinkId = this.serverLinkId, + serverId = this.serverId, + directory = this.directory, + identifier = this.identifier, + title = this.title, + href = this.href, + linkType = ServerLinkType.valueOf(this.linkType), + ) diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/ServerRepository.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/ServerRepository.kt index c4c5099..4f3bf1c 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/ServerRepository.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/data/ServerRepository.kt @@ -21,7 +21,9 @@ package org.comixedproject.variant.shared.data import org.comixedproject.variant.db.ServersDb import org.comixedproject.variant.shared.model.server.Server -class ServerRepository(private val databaseHelper: DatabaseHelper) { +class ServerRepository( + private val databaseHelper: DatabaseHelper, +) { val servers: List get() = databaseHelper.loadServers().map(ServersDb::map) @@ -34,7 +36,7 @@ class ServerRepository(private val databaseHelper: DatabaseHelper) { server.name, server.url, server.username, - server.password + server.password, ) } } @@ -44,10 +46,11 @@ class ServerRepository(private val databaseHelper: DatabaseHelper) { } } -fun ServersDb.map() = Server( - serverId = this.serverId, - name = this.name, - url = this.url, - username = this.username, - password = this.password -) \ No newline at end of file +fun ServersDb.map() = + Server( + serverId = this.serverId, + name = this.name, + url = this.url, + username = this.username, + password = this.password, + ) diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.kt index 4285253..d497a35 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.kt @@ -18,4 +18,4 @@ package org.comixedproject.variant.shared.model -expect abstract class BaseViewModel() \ No newline at end of file +expect abstract class BaseViewModel() diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/Server.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/Server.kt index 98a7389..3c21023 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/Server.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/Server.kt @@ -28,5 +28,5 @@ data class Server( val name: String, val url: String, val username: String, - val password: String -) \ No newline at end of file + val password: String, +) diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/ServerLink.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/ServerLink.kt index 9537120..fb1f7f4 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/ServerLink.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/ServerLink.kt @@ -32,5 +32,5 @@ data class ServerLink( val identifier: String, val title: String? = null, val href: String, - val linkType: ServerLinkType -) \ No newline at end of file + val linkType: ServerLinkType, +) diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/ServerLinkType.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/ServerLinkType.kt index ae95b0a..a7daf4b 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/ServerLinkType.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/model/server/ServerLinkType.kt @@ -25,5 +25,5 @@ package org.comixedproject.variant.shared.model.server */ enum class ServerLinkType { NAVIGATION, - PUBLICATION -} \ No newline at end of file + PUBLICATION, +} diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/platform/Logger.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/platform/Logger.kt index a0f850d..0232259 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/platform/Logger.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/shared/platform/Logger.kt @@ -19,23 +19,43 @@ package org.comixedproject.variant.shared.platform internal expect class Log() { - fun debug(tag: String, message: String) - fun warn(tag: String, message: String) - fun error(tag: String, message: String) + fun debug( + tag: String, + message: String, + ) + + fun warn( + tag: String, + message: String, + ) + + fun error( + tag: String, + message: String, + ) } public object Logger { private val logger = Log() - public fun d(tag: String, message: String) { + public fun d( + tag: String, + message: String, + ) { logger.debug(tag, message) } - public fun w(tag: String, message: String) { + public fun w( + tag: String, + message: String, + ) { logger.warn(tag, message) } - public fun e(tag: String, message: String) { + public fun e( + tag: String, + message: String, + ) { logger.error(tag, message) } -} \ No newline at end of file +} diff --git a/shared/src/commonTest/kotlin/org/comixproject/variant/shared/IDGeneratorTest.kt b/shared/src/commonTest/kotlin/org/comixproject/variant/shared/IDGeneratorTest.kt deleted file mode 100644 index b74cb5e..0000000 --- a/shared/src/commonTest/kotlin/org/comixproject/variant/shared/IDGeneratorTest.kt +++ /dev/null @@ -1,2 +0,0 @@ -package org.comixproject.variant.shared - diff --git a/shared/src/commonTest/kotlin/org/comixproject/variant/shared/KoinIntegrationTest.kt b/shared/src/commonTest/kotlin/org/comixproject/variant/shared/KoinIntegrationTest.kt index ea0a8b2..c677dd9 100644 --- a/shared/src/commonTest/kotlin/org/comixproject/variant/shared/KoinIntegrationTest.kt +++ b/shared/src/commonTest/kotlin/org/comixproject/variant/shared/KoinIntegrationTest.kt @@ -32,7 +32,7 @@ class KoinIntegrationTest { modules( Modules.core, Modules.repositories, - Modules.viewModels + Modules.viewModels, ) }.checkModules() } @@ -41,4 +41,4 @@ class KoinIntegrationTest { fun tearDown() { stopKoin() } -} \ No newline at end of file +} diff --git a/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/IDGenerator.ios.kt b/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/IDGenerator.ios.kt deleted file mode 100644 index d4d201a..0000000 --- a/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/IDGenerator.ios.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Variant - A digital comic book reading application for the iPad and Android tablets. - * Copyright (C) 2024, The ComiXed Project - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -package org.comixedproject.variant.shared - -import platform.Foundation.NSUUID - -actual class IDGenerator actual constructor() { - private val value = NSUUID() - actual override fun toString() = value.UUIDString -} \ No newline at end of file diff --git a/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/KoinIOS.kt b/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/KoinIOS.kt index 7bf5f4c..ff35b0c 100644 --- a/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/KoinIOS.kt +++ b/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/KoinIOS.kt @@ -30,16 +30,18 @@ import org.koin.core.parameter.parametersOf import org.koin.core.qualifier.Qualifier import org.koin.dsl.module -actual val platformModule: Module = module { - single { - NativeSqliteDriver(VariantDb.Schema, "VariantDb") +actual val platformModule: Module = + module { + single { + NativeSqliteDriver(VariantDb.Schema, "VariantDb") + } } -} object KoinIOS { - fun initialize(): KoinApplication = initKoin( - appModule = module { } - ) + fun initialize(): KoinApplication = + initKoin( + appModule = module { }, + ) } @kotlinx.cinterop.BetaInteropApi @@ -49,7 +51,11 @@ fun Koin.get(objCClass: ObjCClass): Any { } @kotlinx.cinterop.BetaInteropApi -fun Koin.get(objCClass: ObjCClass, qualifier: Qualifier?, parameter: Any): Any { +fun Koin.get( + objCClass: ObjCClass, + qualifier: Qualifier?, + parameter: Any, +): Any { val kClazz = getOriginalKotlinClass(objCClass)!! return get(kClazz, qualifier) { parametersOf(parameter) } -} \ No newline at end of file +} diff --git a/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.ios.kt b/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.ios.kt index c955ccf..57670e4 100644 --- a/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.ios.kt +++ b/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/model/BaseViewModel.ios.kt @@ -18,4 +18,4 @@ package org.comixedproject.variant.shared.model -actual abstract class BaseViewModel actual constructor() \ No newline at end of file +actual abstract class BaseViewModel actual constructor() diff --git a/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/platform/Logger.ios.kt b/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/platform/Logger.ios.kt index fb0e9e9..f945a0b 100644 --- a/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/platform/Logger.ios.kt +++ b/shared/src/iosMain/kotlin/org/comixedproject/variant/shared/platform/Logger.ios.kt @@ -21,15 +21,24 @@ package org.comixedproject.variant.shared.platform import platform.Foundation.NSLog internal actual class Log { - actual fun debug(tag: String, message: String) { + actual fun debug( + tag: String, + message: String, + ) { NSLog("$tag | $message") } - actual fun warn(tag: String, message: String) { + actual fun warn( + tag: String, + message: String, + ) { NSLog("$tag | $message") } - actual fun error(tag: String, message: String) { + actual fun error( + tag: String, + message: String, + ) { NSLog("$tag | $message") } -} \ No newline at end of file +}