From bf88d5c8e6d975ee40e8d8cf6fc01412dd1fba9e Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 16 Mar 2024 23:55:01 +0100 Subject: [PATCH] Add ktlint --- .editorconfig | 7 + app/build.gradle.kts | 3 +- .../java/rs/ruffle/ExampleInstrumentedTest.kt | 8 +- app/src/main/java/rs/ruffle/MainActivity.kt | 2 +- app/src/main/java/rs/ruffle/Navigation.kt | 58 +-- .../main/java/rs/ruffle/SelectSwfScreen.kt | 398 +++++++++--------- app/src/main/java/rs/ruffle/TextFieldState.kt | 106 ++--- app/src/main/java/rs/ruffle/UrlState.kt | 44 +- app/src/main/java/rs/ruffle/ui/theme/Color.kt | 7 - app/src/main/java/rs/ruffle/ui/theme/Theme.kt | 26 +- app/src/main/java/rs/ruffle/ui/theme/Type.kt | 18 +- .../test/java/rs/ruffle/ExampleUnitTest.kt | 5 +- build.gradle.kts | 11 +- gradle/libs.versions.toml | 3 +- settings.gradle.kts | 1 - 15 files changed, 352 insertions(+), 345 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dabe208 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*.{kt,kts}] +ktlint_code_style = android_studio +ij_kotlin_name_count_to_use_star_import = 9999 +ij_kotlin_name_count_to_use_star_import_for_members = 9999 +ktlint_function_naming_ignore_when_annotated_with=Composable diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 35eadd6..4f5f271 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -69,7 +69,6 @@ android { } } - splits { // Configures multiple APKs based on ABI. abi { @@ -121,4 +120,4 @@ if (System.getenv("GITHUB_ACTIONS") == null) { apiLevel = 26 buildType = "release" } -} \ No newline at end of file +} diff --git a/app/src/androidTest/java/rs/ruffle/ExampleInstrumentedTest.kt b/app/src/androidTest/java/rs/ruffle/ExampleInstrumentedTest.kt index 5d70503..7241c8a 100644 --- a/app/src/androidTest/java/rs/ruffle/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/rs/ruffle/ExampleInstrumentedTest.kt @@ -1,13 +1,11 @@ package rs.ruffle -import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 - +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith -import org.junit.Assert.* - /** * Instrumented test, which will execute on an Android device. * @@ -21,4 +19,4 @@ class ExampleInstrumentedTest { val appContext = InstrumentationRegistry.getInstrumentation().targetContext assertEquals("rs.ruffle", appContext.packageName) } -} \ No newline at end of file +} diff --git a/app/src/main/java/rs/ruffle/MainActivity.kt b/app/src/main/java/rs/ruffle/MainActivity.kt index 1e78331..a4c0bb2 100644 --- a/app/src/main/java/rs/ruffle/MainActivity.kt +++ b/app/src/main/java/rs/ruffle/MainActivity.kt @@ -6,8 +6,8 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge -import rs.ruffle.ui.theme.RuffleTheme import java.io.IOException +import rs.ruffle.ui.theme.RuffleTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/rs/ruffle/Navigation.kt b/app/src/main/java/rs/ruffle/Navigation.kt index 3a94007..6ff9815 100644 --- a/app/src/main/java/rs/ruffle/Navigation.kt +++ b/app/src/main/java/rs/ruffle/Navigation.kt @@ -1,29 +1,29 @@ -package rs.ruffle - -import android.net.Uri -import androidx.compose.runtime.Composable -import androidx.navigation.NavHostController -import androidx.navigation.compose.NavHost -import androidx.navigation.compose.composable -import androidx.navigation.compose.rememberNavController - -object Destinations { - const val SELECT_SWF_ROUTE = "select" -} - -@Composable -fun RuffleNavHost( - navController: NavHostController = rememberNavController(), - openSwf: (uri: Uri) -> Unit -) { - NavHost( - navController = navController, - startDestination = Destinations.SELECT_SWF_ROUTE, - ) { - composable(Destinations.SELECT_SWF_ROUTE) { - SelectSwfRoute( - openSwf = openSwf - ) - } - } -} \ No newline at end of file +package rs.ruffle + +import android.net.Uri +import androidx.compose.runtime.Composable +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController + +object Destinations { + const val SELECT_SWF_ROUTE = "select" +} + +@Composable +fun RuffleNavHost( + navController: NavHostController = rememberNavController(), + openSwf: (uri: Uri) -> Unit +) { + NavHost( + navController = navController, + startDestination = Destinations.SELECT_SWF_ROUTE + ) { + composable(Destinations.SELECT_SWF_ROUTE) { + SelectSwfRoute( + openSwf = openSwf + ) + } + } +} diff --git a/app/src/main/java/rs/ruffle/SelectSwfScreen.kt b/app/src/main/java/rs/ruffle/SelectSwfScreen.kt index 2548261..d1a17f5 100644 --- a/app/src/main/java/rs/ruffle/SelectSwfScreen.kt +++ b/app/src/main/java/rs/ruffle/SelectSwfScreen.kt @@ -1,200 +1,198 @@ -package rs.ruffle - -import android.content.res.Configuration -import android.net.Uri -import androidx.activity.compose.rememberLauncherForActivityResult -import androidx.activity.result.contract.ActivityResultContracts -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.paddingFromBaseline -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.foundation.text.KeyboardActions -import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material3.Button -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedButton -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.saveable.rememberSaveable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.focus.onFocusChanged -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.input.ImeAction -import androidx.compose.ui.text.input.KeyboardType -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import rs.ruffle.ui.theme.RuffleTheme -import rs.ruffle.ui.theme.slightlyDeemphasizedAlpha - -@Composable -fun BrandBar() { - Image( - painter = painterResource(id = R.drawable.ic_logo_dark), - contentDescription = stringResource(id = R.string.logo_description), - modifier = Modifier - .padding(horizontal = 76.dp) - ) -} - -@Composable -fun SelectSwfRoute( - openSwf: (uri: Uri) -> Unit -) { - SelectSwfScreen( - openSwf = openSwf - ) -} - -@Composable -fun SelectSwfScreen(openSwf: (uri: Uri) -> Unit) { - Scaffold { innerPadding -> - Column( - modifier = Modifier.padding(innerPadding) - ) { - Column( - modifier = Modifier.wrapContentHeight(align = Alignment.CenterVertically) - ) { - BrandBar() - } - Text( - modifier = Modifier.padding(horizontal = 8.dp, vertical = 75.dp), - text = stringResource(id = R.string.work_in_progress_warning) - ) - SelectSwfUrlOrFile(openSwf) - } - } -} - -@Composable -private fun SelectSwfUrlOrFile( - openSwf: (uri: Uri) -> Unit -) { - val urlState by rememberSaveable(stateSaver = UrlStateSaver) { - mutableStateOf(UrlState()) - } - Column( - modifier = Modifier - .padding(horizontal = 20.dp) - ) { - val submitUrl = { - if (urlState.isValid) { - openSwf(Uri.parse(urlState.text)) - } else { - urlState.enableShowErrors() - } - } - OutlinedTextField( - value = urlState.text, - onValueChange = { urlState.text = it }, - modifier = Modifier - .fillMaxWidth() - .onFocusChanged { focusState -> - urlState.onFocusChange(focusState.isFocused) - if (!focusState.isFocused) { - urlState.enableShowErrors() - } - }, - label = { - Text( - text = stringResource(id = R.string.url), - style = MaterialTheme.typography.bodyMedium, - ) - }, - textStyle = MaterialTheme.typography.bodyMedium, - isError = urlState.showErrors(), - keyboardOptions = KeyboardOptions.Default.copy( - imeAction = ImeAction.Go, - keyboardType = KeyboardType.Uri - ), - keyboardActions = KeyboardActions( - onDone = { submitUrl() } - ), - singleLine = true - ) - urlState.getError()?.let { error -> TextFieldError(textError = error) } - - Button( - onClick = submitUrl, - modifier = Modifier - .fillMaxWidth() - .padding(top = 28.dp, bottom = 3.dp) - ) { - Text( - text = stringResource(id = R.string.open_url), - style = MaterialTheme.typography.titleSmall - ) - } - - Column( - horizontalAlignment = Alignment.CenterHorizontally - ) { - Text( - text = stringResource(id = R.string.or), - style = MaterialTheme.typography.titleSmall, - color = MaterialTheme.colorScheme.onSurface.copy(alpha = slightlyDeemphasizedAlpha), - modifier = Modifier.paddingFromBaseline(top = 25.dp) - ) - PickSwfButton(openSwf) - } - } -} - -@Composable -fun PickSwfButton(onSelect: (uri: Uri) -> Unit) { - val launcher = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { - if (it != null) { - onSelect(it) - } - } - - OutlinedButton( - onClick = { - launcher.launch( - "application/x-shockwave-flash" - ) - }, - modifier = Modifier - .fillMaxWidth() - .padding(top = 20.dp, bottom = 24.dp), - - ) { - Text(text = stringResource(id = R.string.select_a_swf)) - } -} - -@Composable -fun TextFieldError(textError: String) { - Row(modifier = Modifier.fillMaxWidth()) { - Spacer(modifier = Modifier.width(16.dp)) - Text( - text = textError, - modifier = Modifier.fillMaxWidth(), - color = MaterialTheme.colorScheme.error - ) - } -} - -@Preview(name = "Select SWF - Light", uiMode = Configuration.UI_MODE_NIGHT_NO) -@Preview(name = "Select SWF - Dark", uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -fun SelectSwfScreenPreview() { - RuffleTheme { - Surface { - SelectSwfScreen( - openSwf = {} - ) - } - } -} \ No newline at end of file +package rs.ruffle + +import android.content.res.Configuration +import android.net.Uri +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.paddingFromBaseline +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.onFocusChanged +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.ImeAction +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import rs.ruffle.ui.theme.RuffleTheme +import rs.ruffle.ui.theme.SLIGHTLY_DEEMPHASIZED_ALPHA + +@Composable +fun BrandBar() { + Image( + painter = painterResource(id = R.drawable.ic_logo_dark), + contentDescription = stringResource(id = R.string.logo_description), + modifier = Modifier + .padding(horizontal = 76.dp) + ) +} + +@Composable +fun SelectSwfRoute(openSwf: (uri: Uri) -> Unit) { + SelectSwfScreen( + openSwf = openSwf + ) +} + +@Composable +fun SelectSwfScreen(openSwf: (uri: Uri) -> Unit) { + Scaffold { innerPadding -> + Column( + modifier = Modifier.padding(innerPadding) + ) { + Column( + modifier = Modifier.wrapContentHeight(align = Alignment.CenterVertically) + ) { + BrandBar() + } + Text( + modifier = Modifier.padding(horizontal = 8.dp, vertical = 75.dp), + text = stringResource(id = R.string.work_in_progress_warning) + ) + SelectSwfUrlOrFile(openSwf) + } + } +} + +@Composable +private fun SelectSwfUrlOrFile(openSwf: (uri: Uri) -> Unit) { + val urlState by rememberSaveable(stateSaver = UrlStateSaver) { + mutableStateOf(UrlState()) + } + Column( + modifier = Modifier + .padding(horizontal = 20.dp) + ) { + val submitUrl = { + if (urlState.isValid) { + openSwf(Uri.parse(urlState.text)) + } else { + urlState.enableShowErrors() + } + } + OutlinedTextField( + value = urlState.text, + onValueChange = { urlState.text = it }, + modifier = Modifier + .fillMaxWidth() + .onFocusChanged { focusState -> + urlState.onFocusChange(focusState.isFocused) + if (!focusState.isFocused) { + urlState.enableShowErrors() + } + }, + label = { + Text( + text = stringResource(id = R.string.url), + style = MaterialTheme.typography.bodyMedium + ) + }, + textStyle = MaterialTheme.typography.bodyMedium, + isError = urlState.showErrors(), + keyboardOptions = KeyboardOptions.Default.copy( + imeAction = ImeAction.Go, + keyboardType = KeyboardType.Uri + ), + keyboardActions = KeyboardActions( + onDone = { submitUrl() } + ), + singleLine = true + ) + urlState.getError()?.let { error -> TextFieldError(textError = error) } + + Button( + onClick = submitUrl, + modifier = Modifier + .fillMaxWidth() + .padding(top = 28.dp, bottom = 3.dp) + ) { + Text( + text = stringResource(id = R.string.open_url), + style = MaterialTheme.typography.titleSmall + ) + } + + Column( + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text( + text = stringResource(id = R.string.or), + style = MaterialTheme.typography.titleSmall, + color = MaterialTheme.colorScheme.onSurface.copy( + alpha = SLIGHTLY_DEEMPHASIZED_ALPHA + ), + modifier = Modifier.paddingFromBaseline(top = 25.dp) + ) + PickSwfButton(openSwf) + } + } +} + +@Composable +fun PickSwfButton(onSelect: (uri: Uri) -> Unit) { + val launcher = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { + if (it != null) { + onSelect(it) + } + } + + OutlinedButton( + onClick = { + launcher.launch( + "application/x-shockwave-flash" + ) + }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 20.dp, bottom = 24.dp) + + ) { + Text(text = stringResource(id = R.string.select_a_swf)) + } +} + +@Composable +fun TextFieldError(textError: String) { + Row(modifier = Modifier.fillMaxWidth()) { + Spacer(modifier = Modifier.width(16.dp)) + Text( + text = textError, + modifier = Modifier.fillMaxWidth(), + color = MaterialTheme.colorScheme.error + ) + } +} + +@Preview(name = "Select SWF - Light", uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(name = "Select SWF - Dark", uiMode = Configuration.UI_MODE_NIGHT_YES) +@Composable +fun SelectSwfScreenPreview() { + RuffleTheme { + Surface { + SelectSwfScreen( + openSwf = {} + ) + } + } +} diff --git a/app/src/main/java/rs/ruffle/TextFieldState.kt b/app/src/main/java/rs/ruffle/TextFieldState.kt index 0abc0dd..94f3713 100644 --- a/app/src/main/java/rs/ruffle/TextFieldState.kt +++ b/app/src/main/java/rs/ruffle/TextFieldState.kt @@ -1,53 +1,53 @@ -package rs.ruffle - -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.saveable.listSaver -import androidx.compose.runtime.setValue - -open class TextFieldState( - private val validator: (String) -> Boolean = { true }, - private val errorFor: (String) -> String = { "" } -) { - var text: String by mutableStateOf("") - - // was the TextField ever focused - var isFocusedDirty: Boolean by mutableStateOf(false) - var isFocused: Boolean by mutableStateOf(false) - private var displayErrors: Boolean by mutableStateOf(false) - - open val isValid: Boolean - get() = validator(text) - - fun onFocusChange(focused: Boolean) { - isFocused = focused - if (focused) isFocusedDirty = true - } - - fun enableShowErrors() { - // only show errors if the text was at least once focused - if (isFocusedDirty) { - displayErrors = true - } - } - - fun showErrors() = !isValid && displayErrors - - open fun getError(): String? { - return if (showErrors()) { - errorFor(text) - } else { - null - } - } -} - -fun textFieldStateSaver(state: TextFieldState) = listSaver( - save = { listOf(it.text, it.isFocusedDirty) }, - restore = { - state.apply { - text = it[0] as String - isFocusedDirty = it[1] as Boolean - } - } -) \ No newline at end of file +package rs.ruffle + +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.listSaver +import androidx.compose.runtime.setValue + +open class TextFieldState( + private val validator: (String) -> Boolean = { true }, + private val errorFor: (String) -> String = { "" } +) { + var text: String by mutableStateOf("") + + // was the TextField ever focused + var isFocusedDirty: Boolean by mutableStateOf(false) + var isFocused: Boolean by mutableStateOf(false) + private var displayErrors: Boolean by mutableStateOf(false) + + open val isValid: Boolean + get() = validator(text) + + fun onFocusChange(focused: Boolean) { + isFocused = focused + if (focused) isFocusedDirty = true + } + + fun enableShowErrors() { + // only show errors if the text was at least once focused + if (isFocusedDirty) { + displayErrors = true + } + } + + fun showErrors() = !isValid && displayErrors + + open fun getError(): String? { + return if (showErrors()) { + errorFor(text) + } else { + null + } + } +} + +fun textFieldStateSaver(state: TextFieldState) = listSaver( + save = { listOf(it.text, it.isFocusedDirty) }, + restore = { + state.apply { + text = it[0] as String + isFocusedDirty = it[1] as Boolean + } + } +) diff --git a/app/src/main/java/rs/ruffle/UrlState.kt b/app/src/main/java/rs/ruffle/UrlState.kt index 3c8c3e5..23d797c 100644 --- a/app/src/main/java/rs/ruffle/UrlState.kt +++ b/app/src/main/java/rs/ruffle/UrlState.kt @@ -1,22 +1,22 @@ -package rs.ruffle - -import android.util.Patterns - -class UrlState(val url: String? = null) : - TextFieldState(validator = ::isUrlValid, errorFor = ::urlValidationError) { - init { - url?.let { - text = it - } - } -} - -private fun urlValidationError(url: String): String { - return "Invalid url: $url" -} - -private fun isUrlValid(url: String): Boolean { - return Patterns.WEB_URL.matcher(url).matches() -} - -val UrlStateSaver = textFieldStateSaver(UrlState()) \ No newline at end of file +package rs.ruffle + +import android.util.Patterns + +class UrlState(val url: String? = null) : + TextFieldState(validator = ::isUrlValid, errorFor = ::urlValidationError) { + init { + url?.let { + text = it + } + } +} + +private fun urlValidationError(url: String): String { + return "Invalid url: $url" +} + +private fun isUrlValid(url: String): Boolean { + return Patterns.WEB_URL.matcher(url).matches() +} + +val UrlStateSaver = textFieldStateSaver(UrlState()) diff --git a/app/src/main/java/rs/ruffle/ui/theme/Color.kt b/app/src/main/java/rs/ruffle/ui/theme/Color.kt index ee049f0..aeb326b 100644 --- a/app/src/main/java/rs/ruffle/ui/theme/Color.kt +++ b/app/src/main/java/rs/ruffle/ui/theme/Color.kt @@ -219,10 +219,3 @@ val surfaceContainerLowDarkHighContrast = Color(0xFF211A12) val surfaceContainerDarkHighContrast = Color(0xFF261E16) val surfaceContainerHighDarkHighContrast = Color(0xFF302920) val surfaceContainerHighestDarkHighContrast = Color(0xFF3C332A) - - - - - - - diff --git a/app/src/main/java/rs/ruffle/ui/theme/Theme.kt b/app/src/main/java/rs/ruffle/ui/theme/Theme.kt index a0ea72f..ff13b24 100644 --- a/app/src/main/java/rs/ruffle/ui/theme/Theme.kt +++ b/app/src/main/java/rs/ruffle/ui/theme/Theme.kt @@ -12,8 +12,8 @@ import androidx.compose.runtime.Immutable import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext -const val stronglyDeemphasizedAlpha = 0.6f -const val slightlyDeemphasizedAlpha = 0.87f +const val STRONGLY_DEEMPHASIZED_ALPHA = 0.6f +const val SLIGHTLY_DEEMPHASIZED_ALPHA = 0.87f private val lightScheme = lightColorScheme( primary = primaryLight, @@ -50,7 +50,7 @@ private val lightScheme = lightColorScheme( surfaceContainerLow = surfaceContainerLowLight, surfaceContainer = surfaceContainerLight, surfaceContainerHigh = surfaceContainerHighLight, - surfaceContainerHighest = surfaceContainerHighestLight, + surfaceContainerHighest = surfaceContainerHighestLight ) private val darkScheme = darkColorScheme( @@ -88,7 +88,7 @@ private val darkScheme = darkColorScheme( surfaceContainerLow = surfaceContainerLowDark, surfaceContainer = surfaceContainerDark, surfaceContainerHigh = surfaceContainerHighDark, - surfaceContainerHighest = surfaceContainerHighestDark, + surfaceContainerHighest = surfaceContainerHighestDark ) private val mediumContrastLightColorScheme = lightColorScheme( @@ -126,7 +126,7 @@ private val mediumContrastLightColorScheme = lightColorScheme( surfaceContainerLow = surfaceContainerLowLightMediumContrast, surfaceContainer = surfaceContainerLightMediumContrast, surfaceContainerHigh = surfaceContainerHighLightMediumContrast, - surfaceContainerHighest = surfaceContainerHighestLightMediumContrast, + surfaceContainerHighest = surfaceContainerHighestLightMediumContrast ) private val highContrastLightColorScheme = lightColorScheme( @@ -164,7 +164,7 @@ private val highContrastLightColorScheme = lightColorScheme( surfaceContainerLow = surfaceContainerLowLightHighContrast, surfaceContainer = surfaceContainerLightHighContrast, surfaceContainerHigh = surfaceContainerHighLightHighContrast, - surfaceContainerHighest = surfaceContainerHighestLightHighContrast, + surfaceContainerHighest = surfaceContainerHighestLightHighContrast ) private val mediumContrastDarkColorScheme = darkColorScheme( @@ -202,7 +202,7 @@ private val mediumContrastDarkColorScheme = darkColorScheme( surfaceContainerLow = surfaceContainerLowDarkMediumContrast, surfaceContainer = surfaceContainerDarkMediumContrast, surfaceContainerHigh = surfaceContainerHighDarkMediumContrast, - surfaceContainerHighest = surfaceContainerHighestDarkMediumContrast, + surfaceContainerHighest = surfaceContainerHighestDarkMediumContrast ) private val highContrastDarkColorScheme = darkColorScheme( @@ -240,7 +240,7 @@ private val highContrastDarkColorScheme = darkColorScheme( surfaceContainerLow = surfaceContainerLowDarkHighContrast, surfaceContainer = surfaceContainerDarkHighContrast, surfaceContainerHigh = surfaceContainerHighDarkHighContrast, - surfaceContainerHighest = surfaceContainerHighestDarkHighContrast, + surfaceContainerHighest = surfaceContainerHighestDarkHighContrast ) @Immutable @@ -252,7 +252,10 @@ data class ColorFamily( ) val unspecified_scheme = ColorFamily( - Color.Unspecified, Color.Unspecified, Color.Unspecified, Color.Unspecified + Color.Unspecified, + Color.Unspecified, + Color.Unspecified, + Color.Unspecified ) @Composable @@ -260,7 +263,9 @@ fun RuffleTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = false, - content: @Composable() () -> Unit + content: + @Composable() + () -> Unit ) { val colorScheme = when { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { @@ -278,4 +283,3 @@ fun RuffleTheme( content = content ) } - diff --git a/app/src/main/java/rs/ruffle/ui/theme/Type.kt b/app/src/main/java/rs/ruffle/ui/theme/Type.kt index 3f04e27..e885935 100644 --- a/app/src/main/java/rs/ruffle/ui/theme/Type.kt +++ b/app/src/main/java/rs/ruffle/ui/theme/Type.kt @@ -8,13 +8,13 @@ import androidx.compose.ui.unit.sp // Set of Material typography styles to start with val Typography = Typography( - bodyLarge = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp, - lineHeight = 24.sp, - letterSpacing = 0.5.sp - ) + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) /* Other default text styles to override titleLarge = TextStyle( fontFamily = FontFamily.Default, @@ -30,5 +30,5 @@ val Typography = Typography( lineHeight = 16.sp, letterSpacing = 0.5.sp ) - */ -) \ No newline at end of file + */ +) diff --git a/app/src/test/java/rs/ruffle/ExampleUnitTest.kt b/app/src/test/java/rs/ruffle/ExampleUnitTest.kt index 12b9fe1..a731df5 100644 --- a/app/src/test/java/rs/ruffle/ExampleUnitTest.kt +++ b/app/src/test/java/rs/ruffle/ExampleUnitTest.kt @@ -1,9 +1,8 @@ package rs.ruffle +import org.junit.Assert.assertEquals import org.junit.Test -import org.junit.Assert.* - /** * Example local unit test, which will execute on the development machine (host). * @@ -14,4 +13,4 @@ class ExampleUnitTest { fun addition_isCorrect() { assertEquals(4, 2 + 2) } -} \ No newline at end of file +} diff --git a/build.gradle.kts b/build.gradle.kts index 7cd7d29..3293523 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { + alias(libs.plugins.ktlint) alias(libs.plugins.androidApplication) apply false alias(libs.plugins.jetbrainsKotlinAndroid) apply false alias(libs.plugins.cargoNdkAndroid) apply false -} \ No newline at end of file +} + +allprojects { + apply(plugin = rootProject.libs.plugins.ktlint.get().pluginId) +} + +ktlint { + android.set(true) +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dffe0c9..d11579d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,6 +14,7 @@ navigationCompose = "2.7.7" gamesActivity = "2.0.2" # Needs to be in sync with android-activity crate constraintlayout = "2.1.4" appcompat = "1.6.1" +ktlint = "12.1.0" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -40,6 +41,6 @@ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } - cargoNdkAndroid = { id = "com.github.willir.rust.cargo-ndk-android", version = "0.3.4" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } diff --git a/settings.gradle.kts b/settings.gradle.kts index ca047f8..013098f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,4 +21,3 @@ dependencyResolutionManagement { rootProject.name = "Ruffle" include(":app") - \ No newline at end of file