From d89d5003192cf11bd9701dddce63d5782b40a071 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 26 Jan 2022 22:41:04 +0530 Subject: [PATCH] Move Compose code to ui-compose module (#1687) --- app/build.gradle.kts | 32 +--------- .../java/dev/msfjarvis/aps/ui/theme/Color.kt | 58 ------------------- ...word-store.binary-compatibility.gradle.kts | 1 + gradle/libs.versions.toml | 1 - settings.gradle.kts | 4 +- ui-compose/build.gradle.kts | 17 ++++++ ui-compose/src/main/AndroidManifest.xml | 6 ++ .../msfjarvis/aps/ui/compose/theme/Color.kt | 58 +++++++++++++++++++ .../msfjarvis/aps/ui/compose}/theme/Theme.kt | 7 ++- .../msfjarvis/aps/ui/compose}/theme/Type.kt | 28 ++++----- 10 files changed, 105 insertions(+), 107 deletions(-) delete mode 100644 app/src/main/java/dev/msfjarvis/aps/ui/theme/Color.kt create mode 100644 ui-compose/build.gradle.kts create mode 100644 ui-compose/src/main/AndroidManifest.xml create mode 100644 ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Color.kt rename {app/src/main/java/dev/msfjarvis/aps/ui => ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose}/theme/Theme.kt (95%) rename {app/src/main/java/dev/msfjarvis/aps/ui => ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose}/theme/Type.kt (84%) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4bb553c9..8247be00 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -13,23 +13,7 @@ plugins { id("dagger.hilt.android.plugin") } -repositories { - val composeSnapshot = libs.versions.composeSnapshot.get() - if (composeSnapshot.length > 1) { - maven("https://androidx.dev/snapshots/builds/$composeSnapshot/artifacts/repository/") { - content { - includeGroup("androidx.compose.animation") - includeGroup("androidx.compose.compiler") - includeGroup("androidx.compose.foundation") - includeGroup("androidx.compose.material") - includeGroup("androidx.compose.runtime") - includeGroup("androidx.compose.ui") - } - } - } -} - -configure { +crowdin { projectName = "android-password-store" skipCleanup = false } @@ -57,8 +41,6 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - buildFeatures.compose = true - lint { abortOnError = true checkReleaseBuilds = false @@ -66,8 +48,6 @@ android { disable.add("PluralsCandidate") disable.add("ImpliedQuantity") } - - composeOptions { kotlinCompilerExtensionVersion = libs.versions.compose.get() } } dependencies { @@ -101,16 +81,6 @@ dependencies { implementation(libs.kotlin.coroutines.android) implementation(libs.kotlin.coroutines.core) - implementation(libs.androidx.activity.compose) - implementation(libs.androidx.hilt.compose) - implementation(libs.compose.foundation.core) - implementation(libs.compose.foundation.layout) - implementation(libs.compose.material) - implementation(libs.androidx.compose.material3) - implementation(libs.compose.ui.core) - implementation(libs.compose.ui.viewbinding) - compileOnly(libs.compose.ui.tooling) - implementation(libs.aps.sublimeFuzzy) implementation(libs.aps.zxingAndroidEmbedded) diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/theme/Color.kt b/app/src/main/java/dev/msfjarvis/aps/ui/theme/Color.kt deleted file mode 100644 index 8566e734..00000000 --- a/app/src/main/java/dev/msfjarvis/aps/ui/theme/Color.kt +++ /dev/null @@ -1,58 +0,0 @@ -package dev.msfjarvis.aps.ui.theme - -import androidx.compose.ui.graphics.Color - -val md_theme_light_primary = Color(0xFF006591) -val md_theme_light_onPrimary = Color(0xFFffffff) -val md_theme_light_primaryContainer = Color(0xFFc7e6ff) -val md_theme_light_onPrimaryContainer = Color(0xFF001e30) -val md_theme_light_secondary = Color(0xFF4f606e) -val md_theme_light_onSecondary = Color(0xFFffffff) -val md_theme_light_secondaryContainer = Color(0xFFd3e5f5) -val md_theme_light_onSecondaryContainer = Color(0xFF0b1d29) -val md_theme_light_tertiary = Color(0xFF006494) -val md_theme_light_onTertiary = Color(0xFFffffff) -val md_theme_light_tertiaryContainer = Color(0xFFc8e6ff) -val md_theme_light_onTertiaryContainer = Color(0xFF001e31) -val md_theme_light_error = Color(0xFFba1b1b) -val md_theme_light_errorContainer = Color(0xFFffdad4) -val md_theme_light_onError = Color(0xFFffffff) -val md_theme_light_onErrorContainer = Color(0xFF410001) -val md_theme_light_background = Color(0xFFfcfcff) -val md_theme_light_onBackground = Color(0xFF1a1c1e) -val md_theme_light_surface = Color(0xFFfcfcff) -val md_theme_light_onSurface = Color(0xFF1a1c1e) -val md_theme_light_surfaceVariant = Color(0xFFdde3ea) -val md_theme_light_onSurfaceVariant = Color(0xFF41474d) -val md_theme_light_outline = Color(0xFF72787e) -val md_theme_light_inverseOnSurface = Color(0xFFf0f0f3) -val md_theme_light_inverseSurface = Color(0xFF2e3133) - -val md_theme_dark_primary = Color(0xFF85ceff) -val md_theme_dark_onPrimary = Color(0xFF00344e) -val md_theme_dark_primaryContainer = Color(0xFF004c6f) -val md_theme_dark_onPrimaryContainer = Color(0xFFc7e6ff) -val md_theme_dark_secondary = Color(0xFFb7c9d9) -val md_theme_dark_onSecondary = Color(0xFF21323e) -val md_theme_dark_secondaryContainer = Color(0xFF384956) -val md_theme_dark_onSecondaryContainer = Color(0xFFd3e5f5) -val md_theme_dark_tertiary = Color(0xFF8aceff) -val md_theme_dark_onTertiary = Color(0xFF003450) -val md_theme_dark_tertiaryContainer = Color(0xFF004b70) -val md_theme_dark_onTertiaryContainer = Color(0xFFc8e6ff) -val md_theme_dark_error = Color(0xFFffb4a9) -val md_theme_dark_errorContainer = Color(0xFF930006) -val md_theme_dark_onError = Color(0xFF680003) -val md_theme_dark_onErrorContainer = Color(0xFFffdad4) -val md_theme_dark_background = Color(0xFF1a1c1e) -val md_theme_dark_onBackground = Color(0xFFe1e2e5) -val md_theme_dark_surface = Color(0xFF1a1c1e) -val md_theme_dark_onSurface = Color(0xFFe1e2e5) -val md_theme_dark_surfaceVariant = Color(0xFF41474d) -val md_theme_dark_onSurfaceVariant = Color(0xFFc1c7ce) -val md_theme_dark_outline = Color(0xFF8b9197) -val md_theme_dark_inverseOnSurface = Color(0xFF1a1c1e) -val md_theme_dark_inverseSurface = Color(0xFFe1e2e5) - -val seed = Color(0xFF003e5b) -val error = Color(0xFFba1b1b) diff --git a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.binary-compatibility.gradle.kts b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.binary-compatibility.gradle.kts index 2aec2844..ad6080e0 100644 --- a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.binary-compatibility.gradle.kts +++ b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.binary-compatibility.gradle.kts @@ -16,5 +16,6 @@ apiValidation { "format-common", "diceware", "random", + "ui-compose", ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dfed1db1..29f83c87 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,6 @@ androidx_activity = "1.4.0" androidx_test = "1.4.1-alpha03" compose = "1.2.0-alpha01" -composeSnapshot = "-" coroutines = "1.6.0" flowbinding = "1.2.0" hilt = "2.40.5" diff --git a/settings.gradle.kts b/settings.gradle.kts index 3b2f4d2a..b0c71a9f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -54,4 +54,6 @@ include("openpgp-ktx") include("passgen:diceware") -include(":passgen:random") +include("passgen:random") + +include("ui-compose") diff --git a/ui-compose/build.gradle.kts b/ui-compose/build.gradle.kts new file mode 100644 index 00000000..e84b0ac1 --- /dev/null +++ b/ui-compose/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id("com.github.android-password-store.android-library") + id("com.github.android-password-store.kotlin-android") + id("com.github.android-password-store.kotlin-library") +} + +dependencies { + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.hilt.compose) + implementation(libs.compose.foundation.core) + implementation(libs.compose.foundation.layout) + implementation(libs.compose.material) + implementation(libs.androidx.compose.material3) + implementation(libs.compose.ui.core) + implementation(libs.compose.ui.viewbinding) + compileOnly(libs.compose.ui.tooling) +} diff --git a/ui-compose/src/main/AndroidManifest.xml b/ui-compose/src/main/AndroidManifest.xml new file mode 100644 index 00000000..482100e7 --- /dev/null +++ b/ui-compose/src/main/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + diff --git a/ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Color.kt b/ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Color.kt new file mode 100644 index 00000000..7f190443 --- /dev/null +++ b/ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Color.kt @@ -0,0 +1,58 @@ +package dev.msfjarvis.aps.ui.compose.theme + +import androidx.compose.ui.graphics.Color + +internal val md_theme_light_primary = Color(0xFF006591) +internal val md_theme_light_onPrimary = Color(0xFFffffff) +internal val md_theme_light_primaryContainer = Color(0xFFc7e6ff) +internal val md_theme_light_onPrimaryContainer = Color(0xFF001e30) +internal val md_theme_light_secondary = Color(0xFF4f606e) +internal val md_theme_light_onSecondary = Color(0xFFffffff) +internal val md_theme_light_secondaryContainer = Color(0xFFd3e5f5) +internal val md_theme_light_onSecondaryContainer = Color(0xFF0b1d29) +internal val md_theme_light_tertiary = Color(0xFF006494) +internal val md_theme_light_onTertiary = Color(0xFFffffff) +internal val md_theme_light_tertiaryContainer = Color(0xFFc8e6ff) +internal val md_theme_light_onTertiaryContainer = Color(0xFF001e31) +internal val md_theme_light_error = Color(0xFFba1b1b) +internal val md_theme_light_errorContainer = Color(0xFFffdad4) +internal val md_theme_light_onError = Color(0xFFffffff) +internal val md_theme_light_onErrorContainer = Color(0xFF410001) +internal val md_theme_light_background = Color(0xFFfcfcff) +internal val md_theme_light_onBackground = Color(0xFF1a1c1e) +internal val md_theme_light_surface = Color(0xFFfcfcff) +internal val md_theme_light_onSurface = Color(0xFF1a1c1e) +internal val md_theme_light_surfaceVariant = Color(0xFFdde3ea) +internal val md_theme_light_onSurfaceVariant = Color(0xFF41474d) +internal val md_theme_light_outline = Color(0xFF72787e) +internal val md_theme_light_inverseOnSurface = Color(0xFFf0f0f3) +internal val md_theme_light_inverseSurface = Color(0xFF2e3133) + +internal val md_theme_dark_primary = Color(0xFF85ceff) +internal val md_theme_dark_onPrimary = Color(0xFF00344e) +internal val md_theme_dark_primaryContainer = Color(0xFF004c6f) +internal val md_theme_dark_onPrimaryContainer = Color(0xFFc7e6ff) +internal val md_theme_dark_secondary = Color(0xFFb7c9d9) +internal val md_theme_dark_onSecondary = Color(0xFF21323e) +internal val md_theme_dark_secondaryContainer = Color(0xFF384956) +internal val md_theme_dark_onSecondaryContainer = Color(0xFFd3e5f5) +internal val md_theme_dark_tertiary = Color(0xFF8aceff) +internal val md_theme_dark_onTertiary = Color(0xFF003450) +internal val md_theme_dark_tertiaryContainer = Color(0xFF004b70) +internal val md_theme_dark_onTertiaryContainer = Color(0xFFc8e6ff) +internal val md_theme_dark_error = Color(0xFFffb4a9) +internal val md_theme_dark_errorContainer = Color(0xFF930006) +internal val md_theme_dark_onError = Color(0xFF680003) +internal val md_theme_dark_onErrorContainer = Color(0xFFffdad4) +internal val md_theme_dark_background = Color(0xFF1a1c1e) +internal val md_theme_dark_onBackground = Color(0xFFe1e2e5) +internal val md_theme_dark_surface = Color(0xFF1a1c1e) +internal val md_theme_dark_onSurface = Color(0xFFe1e2e5) +internal val md_theme_dark_surfaceVariant = Color(0xFF41474d) +internal val md_theme_dark_onSurfaceVariant = Color(0xFFc1c7ce) +internal val md_theme_dark_outline = Color(0xFF8b9197) +internal val md_theme_dark_inverseOnSurface = Color(0xFF1a1c1e) +internal val md_theme_dark_inverseSurface = Color(0xFFe1e2e5) + +internal val seed = Color(0xFF003e5b) +internal val error = Color(0xFFba1b1b) diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/theme/Theme.kt b/ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Theme.kt similarity index 95% rename from app/src/main/java/dev/msfjarvis/aps/ui/theme/Theme.kt rename to ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Theme.kt index 55fb600d..a6652ee1 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/theme/Theme.kt +++ b/ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Theme.kt @@ -1,4 +1,4 @@ -package dev.msfjarvis.aps.ui.theme +package dev.msfjarvis.aps.ui.compose.theme import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme @@ -64,7 +64,10 @@ private val DarkThemeColors = ) @Composable -fun APSTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { +public fun APSTheme( + useDarkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit, +) { val colors = if (!useDarkTheme) { LightThemeColors diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/theme/Type.kt b/ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Type.kt similarity index 84% rename from app/src/main/java/dev/msfjarvis/aps/ui/theme/Type.kt rename to ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Type.kt index 55ee448c..3c256a6a 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/theme/Type.kt +++ b/ui-compose/src/main/kotlin/dev/msfjarvis/aps/ui/compose/theme/Type.kt @@ -1,26 +1,26 @@ -package dev.msfjarvis.aps.ui.theme +package dev.msfjarvis.aps.ui.compose.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp -import dev.msfjarvis.aps.R -// Replace with your font locations -val Manrope = +/** Uncomment the contents below if and when the font files get moved to this module. */ +internal val Manrope = FontFamily( - Font(R.font.manrope_bold, FontWeight.Bold), - Font(R.font.manrope_extrabold, FontWeight.ExtraBold), - Font(R.font.manrope_extralight, FontWeight.ExtraLight), - Font(R.font.manrope_light, FontWeight.Light), - Font(R.font.manrope_medium, FontWeight.Medium), - Font(R.font.manrope_regular, FontWeight.Normal), - Font(R.font.manrope_semibold, FontWeight.SemiBold), - ) + /* + Font(R.font.manrope_bold, FontWeight.Bold), + Font(R.font.manrope_extrabold, FontWeight.ExtraBold), + Font(R.font.manrope_extralight, FontWeight.ExtraLight), + Font(R.font.manrope_light, FontWeight.Light), + Font(R.font.manrope_medium, FontWeight.Medium), + Font(R.font.manrope_regular, FontWeight.Normal), + Font(R.font.manrope_semibold, FontWeight.SemiBold), + */ + ) -val AppTypography = +internal val AppTypography = Typography( displayLarge = TextStyle(