mirror of
https://github.com/ruffle-rs/ruffle-android.git
synced 2024-11-23 05:39:38 +00:00
Add ktlint
This commit is contained in:
parent
e395c087b4
commit
bf88d5c8e6
7
.editorconfig
Normal file
7
.editorconfig
Normal file
@ -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
|
@ -69,7 +69,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
splits {
|
||||
// Configures multiple APKs based on ABI.
|
||||
abi {
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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?) {
|
||||
|
@ -18,7 +18,7 @@ fun RuffleNavHost(
|
||||
) {
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = Destinations.SELECT_SWF_ROUTE,
|
||||
startDestination = Destinations.SELECT_SWF_ROUTE
|
||||
) {
|
||||
composable(Destinations.SELECT_SWF_ROUTE) {
|
||||
SelectSwfRoute(
|
||||
|
@ -36,7 +36,7 @@ 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
|
||||
import rs.ruffle.ui.theme.SLIGHTLY_DEEMPHASIZED_ALPHA
|
||||
|
||||
@Composable
|
||||
fun BrandBar() {
|
||||
@ -49,9 +49,7 @@ fun BrandBar() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SelectSwfRoute(
|
||||
openSwf: (uri: Uri) -> Unit
|
||||
) {
|
||||
fun SelectSwfRoute(openSwf: (uri: Uri) -> Unit) {
|
||||
SelectSwfScreen(
|
||||
openSwf = openSwf
|
||||
)
|
||||
@ -78,9 +76,7 @@ fun SelectSwfScreen(openSwf: (uri: Uri) -> Unit) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SelectSwfUrlOrFile(
|
||||
openSwf: (uri: Uri) -> Unit
|
||||
) {
|
||||
private fun SelectSwfUrlOrFile(openSwf: (uri: Uri) -> Unit) {
|
||||
val urlState by rememberSaveable(stateSaver = UrlStateSaver) {
|
||||
mutableStateOf(UrlState())
|
||||
}
|
||||
@ -109,7 +105,7 @@ private fun SelectSwfUrlOrFile(
|
||||
label = {
|
||||
Text(
|
||||
text = stringResource(id = R.string.url),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
},
|
||||
textStyle = MaterialTheme.typography.bodyMedium,
|
||||
@ -143,7 +139,9 @@ private fun SelectSwfUrlOrFile(
|
||||
Text(
|
||||
text = stringResource(id = R.string.or),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = slightlyDeemphasizedAlpha),
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(
|
||||
alpha = SLIGHTLY_DEEMPHASIZED_ALPHA
|
||||
),
|
||||
modifier = Modifier.paddingFromBaseline(top = 25.dp)
|
||||
)
|
||||
PickSwfButton(openSwf)
|
||||
@ -167,7 +165,7 @@ fun PickSwfButton(onSelect: (uri: Uri) -> Unit) {
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 20.dp, bottom = 24.dp),
|
||||
.padding(top = 20.dp, bottom = 24.dp)
|
||||
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.select_a_swf))
|
||||
|
@ -219,10 +219,3 @@ val surfaceContainerLowDarkHighContrast = Color(0xFF211A12)
|
||||
val surfaceContainerDarkHighContrast = Color(0xFF261E16)
|
||||
val surfaceContainerHighDarkHighContrast = Color(0xFF302920)
|
||||
val surfaceContainerHighestDarkHighContrast = Color(0xFF3C332A)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -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).
|
||||
*
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply(plugin = rootProject.libs.plugins.ktlint.get().pluginId)
|
||||
}
|
||||
|
||||
ktlint {
|
||||
android.set(true)
|
||||
}
|
||||
|
@ -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" }
|
||||
|
||||
|
@ -21,4 +21,3 @@ dependencyResolutionManagement {
|
||||
|
||||
rootProject.name = "Ruffle"
|
||||
include(":app")
|
||||
|
Loading…
Reference in New Issue
Block a user