diff --git a/.editorconfig b/.editorconfig index 5e502e8e..6200679f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,9 @@ [*.{kt,kts}] +max_line_length = 120 indent_size = 4 insert_final_newline = true +ktlint_code_style = intellij_idea +ktlint_function_naming_ignore_when_annotated_with = Composable ij_kotlin_allow_trailing_comma = true ij_kotlin_allow_trailing_comma_on_call_site = true ij_kotlin_name_count_to_use_star_import = 2147483647 diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2d251d34..829e8301 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -8,7 +8,7 @@ plugins { id("dagger.hilt.android.plugin") alias(libs.plugins.ksp) alias(libs.plugins.apollo) - alias(libs.plugins.kotlinter) + alias(libs.plugins.ktlint) alias(libs.plugins.autoresconfig) } @@ -149,11 +149,12 @@ apollo { } } -kotlinter { - experimentalRules = true - - // Doesn't play well with Android Studio - disabledRules = arrayOf("experimental:argument-list-wrapping") +ktlint { + filter { + exclude { element -> + element.file.path.contains("generated/") + } + } } tasks { diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/App.kt b/app/src/main/kotlin/me/echeung/moemoekyun/App.kt index b6e42220..bc2f4e7f 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/App.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/App.kt @@ -83,7 +83,10 @@ class App : Application(), DefaultLifecycleObserver, ServiceConnection, ImageLoa val notificationManager = NotificationManagerCompat.from(this) listOf( // Playing - NotificationChannelCompat.Builder(MusicNotifier.NOTIFICATION_CHANNEL_ID, NotificationManagerCompat.IMPORTANCE_LOW) + NotificationChannelCompat.Builder( + MusicNotifier.NOTIFICATION_CHANNEL_ID, + NotificationManagerCompat.IMPORTANCE_LOW, + ) .setName(MusicNotifier.NOTIFICATION_CHANNEL_NAME) .build(), ).forEach(notificationManager::createNotificationChannel) diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/client/api/APIClient.kt b/app/src/main/kotlin/me/echeung/moemoekyun/client/api/ApiClient.kt similarity index 90% rename from app/src/main/kotlin/me/echeung/moemoekyun/client/api/APIClient.kt rename to app/src/main/kotlin/me/echeung/moemoekyun/client/api/ApiClient.kt index 0eec28f6..c655b936 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/client/api/APIClient.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/client/api/ApiClient.kt @@ -93,7 +93,9 @@ class ApiClient @Inject constructor( */ suspend fun getUserFavorites(): List { // TODO: do actual pagination - val response = client.query(FavoritesQuery("@me", 0, 2500, Optional.presentIfNotNull(preferenceUtil.station().get() == Station.KPOP))).execute() + val response = client.query( + FavoritesQuery("@me", 0, 2500, Optional.presentIfNotNull(preferenceUtil.station().get() == Station.KPOP)), + ).execute() return response.data?.user?.favorites?.favorites ?.mapNotNull { it?.transform() } @@ -115,7 +117,9 @@ class ApiClient @Inject constructor( * @param songId Song to request. */ suspend fun requestSong(songId: Int) { - val response = client.mutation(RequestSongMutation(songId, Optional.presentIfNotNull(preferenceUtil.station().get() == Station.KPOP))).execute() + val response = client.mutation( + RequestSongMutation(songId, Optional.presentIfNotNull(preferenceUtil.station().get() == Station.KPOP)), + ).execute() if (response.hasErrors()) { throw Exception(response.errors.toMessage()) @@ -142,7 +146,9 @@ class ApiClient @Inject constructor( suspend fun getAllSongs(): List { // TODO: do actual pagination // TODO: maintain an actual DB of song info so we don't need to query as much stuff - val response = client.query(SongsQuery(0, 50000, Optional.presentIfNotNull(preferenceUtil.station().get() == Station.KPOP))) + val response = client.query( + SongsQuery(0, 50000, Optional.presentIfNotNull(preferenceUtil.station().get() == Station.KPOP)), + ) .httpFetchPolicy(HttpFetchPolicy.CacheFirst) .httpExpireTimeout(TimeUnit.DAYS.toMillis(1)) .execute() diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/client/api/Stream.kt b/app/src/main/kotlin/me/echeung/moemoekyun/client/api/Stream.kt index 8836cfb5..2d71c5fc 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/client/api/Stream.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/client/api/Stream.kt @@ -84,7 +84,10 @@ class Stream @Inject constructor( AudioManager.AUDIOFOCUS_LOSS, AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> { wasPlayingBeforeLoss = isPlaying - if (wasPlayingBeforeLoss && (preferenceUtil.shouldPauseAudioOnLoss().get() || context.isCarUiMode())) { + if ( + wasPlayingBeforeLoss && + (preferenceUtil.shouldPauseAudioOnLoss().get() || context.isCarUiMode()) + ) { pause() } } @@ -153,7 +156,10 @@ class Stream @Inject constructor( // Set stream val streamUrl = preferenceUtil.station().get().streamUrl if (streamUrl != currentStreamUrl) { - val dataSourceFactory = DefaultDataSource.Factory(context, DefaultHttpDataSource.Factory().setUserAgent(NetworkUtil.userAgent)) + val dataSourceFactory = DefaultDataSource.Factory( + context, + DefaultHttpDataSource.Factory().setUserAgent(NetworkUtil.userAgent), + ) val streamSource = ProgressiveMediaSource.Factory(dataSourceFactory, DefaultExtractorsFactory()) .createMediaSource(MediaItem.Builder().setUri(Uri.parse(streamUrl)).build()) with(player!!) { diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/di/SingletonModule.kt b/app/src/main/kotlin/me/echeung/moemoekyun/di/SingletonModule.kt index cb187030..61a93a51 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/di/SingletonModule.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/di/SingletonModule.kt @@ -34,9 +34,7 @@ object SingletonModule { @Provides @Singleton - fun okhttpClient( - authUtil: AuthUtil, - ): OkHttpClient { + fun okhttpClient(authUtil: AuthUtil): OkHttpClient { val builder = OkHttpClient.Builder() .addNetworkInterceptor { chain -> val request = chain.request() @@ -72,10 +70,7 @@ object SingletonModule { @Provides @Singleton - fun apolloClient( - @ApplicationContext context: Context, - okHttpClient: OkHttpClient, - ) = ApolloClient.Builder() + fun apolloClient(@ApplicationContext context: Context, okHttpClient: OkHttpClient) = ApolloClient.Builder() .serverUrl("https://listen.moe/graphql") .httpCache( directory = File(context.externalCacheDir, "apolloCache"), diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/domain/songs/interactor/GetFavoriteSongs.kt b/app/src/main/kotlin/me/echeung/moemoekyun/domain/songs/interactor/GetFavoriteSongs.kt index 71c9a920..8d7198c4 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/domain/songs/interactor/GetFavoriteSongs.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/domain/songs/interactor/GetFavoriteSongs.kt @@ -27,7 +27,11 @@ class GetFavoriteSongs @Inject constructor( fun getAll(): List { return userService.state.value.favorites.let { - songsSorter.sort(it, preferenceUtil.favoritesSortType().get(), preferenceUtil.favoritesSortDescending().get()) + songsSorter.sort( + it, + preferenceUtil.favoritesSortType().get(), + preferenceUtil.favoritesSortDescending().get(), + ) } } diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/domain/songs/model/Song.kt b/app/src/main/kotlin/me/echeung/moemoekyun/domain/songs/model/DomainSong.kt similarity index 100% rename from app/src/main/kotlin/me/echeung/moemoekyun/domain/songs/model/Song.kt rename to app/src/main/kotlin/me/echeung/moemoekyun/domain/songs/model/DomainSong.kt diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/service/MusicNotifier.kt b/app/src/main/kotlin/me/echeung/moemoekyun/service/MusicNotifier.kt index e41a89a5..94d48f8f 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/service/MusicNotifier.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/service/MusicNotifier.kt @@ -36,7 +36,12 @@ class MusicNotifier @Inject constructor( flags = Intent.FLAG_ACTIVITY_SINGLE_TOP } - val clickIntent = PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + val clickIntent = PendingIntent.getActivity( + service, + 0, + action, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, + ) val deleteIntent = getPlaybackActionService(service, AppService.STOP) val builder = NotificationCompat.Builder(service, NOTIFICATION_CHANNEL_ID) @@ -52,7 +57,9 @@ class MusicNotifier @Inject constructor( .setOnlyAlertOnce(true) // Needs to be set after setting the color - val style = androidx.media.app.NotificationCompat.MediaStyle().setMediaSession(service.mediaSession!!.sessionToken) + val style = androidx.media.app.NotificationCompat.MediaStyle().setMediaSession( + service.mediaSession!!.sessionToken, + ) builder.setStyle(style.setShowActionsInCompactView(0)) builder.setContentTitle(currentSong.title) @@ -64,9 +71,13 @@ class MusicNotifier @Inject constructor( builder.addAction( NotificationCompat.Action( if (currentSong.favorited) R.drawable.ic_star_24dp else R.drawable.ic_star_border_24dp, - if (currentSong.favorited) service.getString(R.string.action_unfavorite) else service.getString( - R.string.action_favorite, - ), + if (currentSong.favorited) { + service.getString(R.string.action_unfavorite) + } else { + service.getString( + R.string.action_favorite, + ) + }, getPlaybackActionService(service, AppService.TOGGLE_FAVORITE), ), ) @@ -90,7 +101,12 @@ class MusicNotifier @Inject constructor( action = intentAction } - return PendingIntent.getService(service, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getService( + service, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, + ) } companion object { diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/AlbumArt.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/AlbumArt.kt index 0497b7d6..1a8ad853 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/AlbumArt.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/AlbumArt.kt @@ -18,11 +18,7 @@ private val AlbumArtModifier = Modifier .clip(RoundedCornerShape(8.dp)) @Composable -fun AlbumArt( - albumArtUrl: String?, - modifier: Modifier = Modifier, - openUrlOnClick: Boolean = true, -) { +fun AlbumArt(albumArtUrl: String?, modifier: Modifier = Modifier, openUrlOnClick: Boolean = true) { val uriHandler = LocalUriHandler.current if (albumArtUrl == null) { diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/BackgroundBox.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/BackgroundBox.kt index c08f20e2..d8c3ec0c 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/BackgroundBox.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/BackgroundBox.kt @@ -10,10 +10,7 @@ import androidx.compose.ui.res.painterResource import me.echeung.moemoekyun.R @Composable -fun BackgroundBox( - modifier: Modifier = Modifier, - content: @Composable BoxScope.() -> Unit, -) { +fun BackgroundBox(modifier: Modifier = Modifier, content: @Composable BoxScope.() -> Unit) { Box( modifier = modifier, ) { diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/Constants.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/Constants.kt index fbfffa9d..1f43dd41 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/Constants.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/Constants.kt @@ -3,6 +3,6 @@ package me.echeung.moemoekyun.ui.common import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha -const val SecondaryItemAlpha = .78f +const val SECONDARY_ITEM_ALPHA = .78f -fun Modifier.secondaryItemAlpha(): Modifier = this.alpha(SecondaryItemAlpha) +fun Modifier.secondaryItemAlpha(): Modifier = this.alpha(SECONDARY_ITEM_ALPHA) diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/DropdownMenu.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/DropdownMenu.kt index b5cf04c6..47d9e2f0 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/DropdownMenu.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/DropdownMenu.kt @@ -35,10 +35,7 @@ fun DropdownMenu( } @Composable -fun RadioIcon( - checked: Boolean, - modifier: Modifier = Modifier, -) { +fun RadioIcon(checked: Boolean, modifier: Modifier = Modifier) { if (checked) { Icon( Icons.Outlined.RadioButtonChecked, @@ -55,10 +52,7 @@ fun RadioIcon( } @Composable -fun CheckboxIcon( - checked: Boolean, - modifier: Modifier = Modifier, -) { +fun CheckboxIcon(checked: Boolean, modifier: Modifier = Modifier) { if (checked) { Icon( Icons.Outlined.CheckBox, diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/LoadingScreen.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/LoadingScreen.kt index 21aa0235..72b067eb 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/LoadingScreen.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/LoadingScreen.kt @@ -8,9 +8,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @Composable -fun LoadingScreen( - modifier: Modifier = Modifier, -) { +fun LoadingScreen(modifier: Modifier = Modifier) { Box( modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center, diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/SongsList.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/SongsList.kt index 3acdab61..78b6936c 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/SongsList.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/SongsList.kt @@ -17,10 +17,7 @@ import kotlinx.collections.immutable.ImmutableList import me.echeung.moemoekyun.domain.songs.model.DomainSong import me.echeung.moemoekyun.ui.screen.songs.SongsScreen -fun LazyListScope.songsItems( - songs: ImmutableList, - showFavoriteIcons: Boolean = false, -) = items( +fun LazyListScope.songsItems(songs: ImmutableList, showFavoriteIcons: Boolean = false) = items( items = songs, key = { it.id }, ) { diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/Toolbar.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/Toolbar.kt index 86188ed8..c0db2a12 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/Toolbar.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/Toolbar.kt @@ -71,9 +71,7 @@ fun Toolbar( } @Composable -fun UpButton( - modifier: Modifier = Modifier, -) { +fun UpButton(modifier: Modifier = Modifier) { val navigator = LocalNavigator.currentOrThrow IconButton( @@ -88,11 +86,7 @@ fun UpButton( } @Composable -fun SearchTextInput( - query: String?, - modifier: Modifier = Modifier, - onQueryChange: (String) -> Unit, -) { +fun SearchTextInput(query: String?, modifier: Modifier = Modifier, onQueryChange: (String) -> Unit) { val focusManager = LocalFocusManager.current val focusRequester = remember { FocusRequester() } diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/preferences/ListPreference.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/preferences/ListPreference.kt index 891c11c2..d29a5553 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/preferences/ListPreference.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/preferences/ListPreference.kt @@ -76,11 +76,7 @@ fun ListPreference( } @Composable -private fun DialogRow( - label: String, - isSelected: Boolean, - onSelected: () -> Unit, -) { +private fun DialogRow(label: String, isSelected: Boolean, onSelected: () -> Unit) { Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/preferences/PreferenceGroupHeader.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/preferences/PreferenceGroupHeader.kt index 9cbe5122..9dfaf103 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/preferences/PreferenceGroupHeader.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/common/preferences/PreferenceGroupHeader.kt @@ -11,10 +11,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp @Composable -fun PreferenceGroupHeader( - title: String, - modifier: Modifier = Modifier, -) { +fun PreferenceGroupHeader(title: String, modifier: Modifier = Modifier) { Box( contentAlignment = Alignment.CenterStart, modifier = modifier diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/about/AboutScreen.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/about/AboutScreen.kt index 4b9e5e05..2d114497 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/about/AboutScreen.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/about/AboutScreen.kt @@ -94,7 +94,9 @@ object AboutScreen : Screen { if (BuildConfig.FLAVOR == "playstore") { AboutCardItem(Icons.Default.Star, R.string.rate) { - uriHandler.openUri("https://play.google.com/store/apps/details?id=me.echeung.moemoekyun") + uriHandler.openUri( + "https://play.google.com/store/apps/details?id=me.echeung.moemoekyun", + ) } } AboutCardItem(Icons.Default.Language, R.string.translate) { @@ -148,10 +150,7 @@ object AboutScreen : Screen { } @Composable -private fun AboutCard( - @StringRes headingResId: Int? = null, - content: @Composable () -> Unit, -) { +private fun AboutCard(@StringRes headingResId: Int? = null, content: @Composable () -> Unit) { Box(modifier = Modifier.padding(vertical = 8.dp)) { Card( modifier = Modifier.fillMaxWidth(), @@ -178,11 +177,7 @@ private fun AboutCard( } @Composable -private fun AboutCardItem( - imageVector: ImageVector, - @StringRes textResId: Int, - onClick: () -> Unit = {}, -) { +private fun AboutCardItem(imageVector: ImageVector, @StringRes textResId: Int, onClick: () -> Unit = {}) { TextButton( modifier = Modifier .fillMaxWidth() diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/auth/LoginScreen.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/auth/LoginScreen.kt index 6cb5fe50..ee3cbaef 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/auth/LoginScreen.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/auth/LoginScreen.kt @@ -126,7 +126,8 @@ object LoginScreen : Screen { when (state.result) { is LoginScreenModel.Result.InvalidOtp -> stringResource(R.string.invalid_mfa_token) - is LoginScreenModel.Result.ApiError -> (state.result as LoginScreenModel.Result.ApiError).message + is LoginScreenModel.Result.ApiError -> + (state.result as LoginScreenModel.Result.ApiError).message else -> null }?.let { Text( diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/auth/RegisterScreen.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/auth/RegisterScreen.kt index ffb793d5..1e54b653 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/auth/RegisterScreen.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/auth/RegisterScreen.kt @@ -110,7 +110,8 @@ object RegisterScreen : Screen { when (state.result) { is RegisterScreenModel.Result.AllFieldsRequired -> stringResource(R.string.required) is RegisterScreenModel.Result.MismatchedPasswords -> stringResource(R.string.password_mismatch) - is RegisterScreenModel.Result.ApiError -> (state.result as RegisterScreenModel.Result.ApiError).message + is RegisterScreenModel.Result.ApiError -> + (state.result as RegisterScreenModel.Result.ApiError).message else -> null }?.let { Text( diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/AuthedHomeContent.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/AuthedHomeContent.kt index 75b49ed9..b60a807f 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/AuthedHomeContent.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/AuthedHomeContent.kt @@ -104,10 +104,7 @@ private val UserAvatarModifier = Modifier private val BannerScrim = Color.Black.copy(alpha = 0.65f) @Composable -private fun UserInfo( - user: DomainUser, - onClickLogOut: () -> Unit, -) { +private fun UserInfo(user: DomainUser, onClickLogOut: () -> Unit) { val uriHandler = LocalUriHandler.current var showLogoutConfirmation by remember { mutableStateOf(false) } diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/HomeScreen.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/HomeScreen.kt index 23f3bde4..3b7bdf4f 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/HomeScreen.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/HomeScreen.kt @@ -84,9 +84,7 @@ object HomeScreen : Screen { } @Composable - private fun Toolbar( - isAuthenticated: Boolean, - ) { + private fun Toolbar(isAuthenticated: Boolean) { val navigator = LocalNavigator.currentOrThrow TopAppBar( diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/Player.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/Player.kt index a9bbbb52..68181bb2 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/Player.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/Player.kt @@ -163,11 +163,7 @@ private fun PlayerContent( } @Composable -private fun BoxScope.CollapsedPlayerContent( - radioState: RadioState, - togglePlayState: () -> Unit, - onClick: () -> Unit, -) { +private fun BoxScope.CollapsedPlayerContent(radioState: RadioState, togglePlayState: () -> Unit, onClick: () -> Unit) { Surface( modifier = Modifier .align(Alignment.BottomCenter) @@ -348,9 +344,7 @@ private fun LandscapeExpandedPlayerContent( } @Composable -private fun CollapseIcon( - onClickCollapse: () -> Unit, -) { +private fun CollapseIcon(onClickCollapse: () -> Unit) { Box( modifier = Modifier .fillMaxWidth() @@ -367,10 +361,7 @@ private fun CollapseIcon( } @Composable -private fun StationPicker( - radioState: RadioState, - onClickStation: (Station) -> Unit, -) { +private fun StationPicker(radioState: RadioState, onClickStation: (Station) -> Unit) { val colors = SegmentedButtonDefaults.colors( activeContainerColor = MaterialTheme.colorScheme.primary, inactiveContainerColor = MaterialTheme.colorScheme.surface.copy(alpha = 0.5f), diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/UnauthedHomeContent.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/UnauthedHomeContent.kt index 867d4264..352946ed 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/UnauthedHomeContent.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/home/UnauthedHomeContent.kt @@ -28,9 +28,7 @@ import me.echeung.moemoekyun.ui.screen.auth.RegisterScreen import me.echeung.moemoekyun.ui.theme.AppTheme @Composable -fun UnauthedHomeContent( - modifier: Modifier = Modifier, -) { +fun UnauthedHomeContent(modifier: Modifier = Modifier) { val navigator = LocalNavigator.currentOrThrow Column( diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/settings/SettingsScreen.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/settings/SettingsScreen.kt index c5b537a2..20cf79fa 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/settings/SettingsScreen.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/settings/SettingsScreen.kt @@ -36,7 +36,9 @@ object SettingsScreen : Screen { val screenModel = getScreenModel() val langs = remember { getLangs(context) } - var currentLanguage by remember { mutableStateOf(AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: "") } + var currentLanguage by remember { + mutableStateOf(AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: "") + } LaunchedEffect(currentLanguage) { val locale = if (currentLanguage.isEmpty()) { diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/songs/SongDetails.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/songs/SongDetails.kt index a220c640..51a286ad 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/songs/SongDetails.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/screen/songs/SongDetails.kt @@ -106,10 +106,7 @@ fun SongDetails( } @Composable -private fun ColumnScope.Section( - @StringRes heading: Int, - value: String?, -) { +private fun ColumnScope.Section(@StringRes heading: Int, value: String?) { val context = LocalContext.current value.orEmpty().takeIf { it.isNotBlank() }?.let { diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/ui/util/Modifier.kt b/app/src/main/kotlin/me/echeung/moemoekyun/ui/util/Modifier.kt index f112d362..7a79e5da 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/ui/util/Modifier.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/ui/util/Modifier.kt @@ -13,10 +13,7 @@ import androidx.compose.ui.platform.LocalAutofillTree // Yoinked from https://issuetracker.google.com/issues/176949051#comment8 @OptIn(ExperimentalComposeUiApi::class) -fun Modifier.autofill( - autofillTypes: List, - onFill: (String) -> Unit, -) = composed { +fun Modifier.autofill(autofillTypes: List, onFill: (String) -> Unit) = composed { val autofill = LocalAutofill.current val autofillNode = AutofillNode(onFill = onFill, autofillTypes = autofillTypes) LocalAutofillTree.current += autofillNode diff --git a/app/src/main/kotlin/me/echeung/moemoekyun/util/ext/CoroutineExtensions.kt b/app/src/main/kotlin/me/echeung/moemoekyun/util/ext/CoroutineExtensions.kt index 3db4ef01..de2e75f9 100644 --- a/app/src/main/kotlin/me/echeung/moemoekyun/util/ext/CoroutineExtensions.kt +++ b/app/src/main/kotlin/me/echeung/moemoekyun/util/ext/CoroutineExtensions.kt @@ -6,8 +6,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -fun CoroutineScope.launchIO(block: suspend CoroutineScope.() -> Unit): Job = - launch(Dispatchers.IO, block = block) +fun CoroutineScope.launchIO(block: suspend CoroutineScope.() -> Unit): Job = launch(Dispatchers.IO, block = block) suspend fun withUIContext(block: suspend CoroutineScope.() -> T) = withContext(Dispatchers.Main, block) diff --git a/build.gradle.kts b/build.gradle.kts index d8d792bf..e46eaa53 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { alias(libs.plugins.serialization) apply false alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.ksp) apply false - alias(libs.plugins.kotlinter) apply false + alias(libs.plugins.ktlint) apply false alias(libs.plugins.autoresconfig) apply false } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 333fb45c..0d71de20 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,7 +18,7 @@ serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref ksp = { id = "com.google.devtools.ksp", version = "1.9.22-1.0.18" } apollo = { id = "com.apollographql.apollo3", version.ref = "apollo_version" } -kotlinter = { id = "org.jmailen.kotlinter", version = "3.11.1" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "12.1.0" } autoresconfig = { id = "dev.rikka.tools.autoresconfig", version = "1.2.2" } [libraries]