diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c1146ab..e5b5839 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,16 +1,17 @@ +import com.wei.picquest.PqBuildType + plugins { - id("com.android.application") - id("org.jetbrains.kotlin.android") + alias(libs.plugins.pq.android.application) + alias(libs.plugins.pq.android.application.compose) + alias(libs.plugins.pq.android.application.flavors) + alias(libs.plugins.pq.android.hilt) } android { namespace = "com.wei.picquest" - compileSdk = 34 defaultConfig { applicationId = "com.wei.picquest" - minSdk = 21 - targetSdk = 34 /** * Version Code: AABCXYZ * @@ -28,7 +29,9 @@ android { */ versionName = "0.0.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + // Custom test runner to set up Hilt dependency graph + testInstrumentationRunner = "com.wei.picquest.core.testing.PqTestRunner" + vectorDrawables { useSupportLibrary = true } @@ -44,21 +47,20 @@ android { } } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - } - - buildFeatures { - compose = true - } + buildTypes { + debug { + applicationIdSuffix = PqBuildType.DEBUG.applicationIdSuffix + } + release { + isMinifyEnabled = true + applicationIdSuffix = PqBuildType.RELEASE.applicationIdSuffix + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - composeOptions { - kotlinCompilerExtensionVersion = "1.5.3" + // To publish on the Play store a private signing key is required, but to allow anyone + // who clones the code to sign and run the release variant, use the debug signing key. + // TODO: Abstract the signing configuration to a separate file to avoid hardcoding this. + signingConfig = signingConfigs.getByName("debug") + } } packaging { @@ -66,7 +68,6 @@ android { excludes.add("/META-INF/{AL2.0,LGPL2.1}") } } - testOptions { unitTests { isIncludeAndroidResources = true @@ -75,20 +76,46 @@ android { } dependencies { + // TODO Wei +// implementation(project(":feature:login")) +// implementation(project(":feature:home")) +// implementation(project(":feature:contactme")) + + implementation(project(":core:designsystem")) + implementation(project(":core:common")) + implementation(project(":core:data")) + implementation(project(":core:model")) +// implementation(project(":core:datastore")) + + androidTestImplementation(project(":core:designsystem")) +// androidTestImplementation(project(":core:datastore-test")) + androidTestImplementation(project(":core:testing")) + androidTestImplementation(libs.androidx.navigation.testing) + androidTestImplementation(libs.accompanist.testharness) +// testImplementation(project(":core:datastore-test")) + testImplementation(project(":core:testing")) + testImplementation(libs.androidx.navigation.testing) + testImplementation(libs.accompanist.testharness) + debugImplementation(project(":ui-test-hilt-manifest")) + debugImplementation(libs.androidx.compose.ui.testManifest) + + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.activity.compose) + + // LifeCycle + implementation(libs.androidx.lifecycle.livedata.ktx) + implementation(libs.androidx.lifecycle.runtimeCompose) + + // Navigation + implementation(libs.androidx.hilt.navigation.compose) + implementation(libs.androidx.navigation.compose) + + // Coroutines + implementation(libs.kotlinx.coroutines.android) + + // Splashscreen + implementation(libs.androidx.core.splashscreen) - implementation("androidx.core:core-ktx:1.12.0") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2") - implementation("androidx.activity:activity-compose:1.8.1") - implementation(platform("androidx.compose:compose-bom:2023.08.00")) - implementation("androidx.compose.ui:ui") - implementation("androidx.compose.ui:ui-graphics") - implementation("androidx.compose.ui:ui-tooling-preview") - implementation("androidx.compose.material3:material3") - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.5") - androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") - androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00")) - androidTestImplementation("androidx.compose.ui:ui-test-junit4") - debugImplementation("androidx.compose.ui:ui-tooling") - debugImplementation("androidx.compose.ui:ui-test-manifest") + // Timber + implementation(libs.timber) } \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..e89647e 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html @@ -18,4 +18,24 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-dontwarn org.bouncycastle.jsse.BCSSLParameters +-dontwarn org.bouncycastle.jsse.BCSSLSocket +-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider +-dontwarn org.conscrypt.Conscrypt$Version +-dontwarn org.conscrypt.Conscrypt +-dontwarn org.conscrypt.ConscryptHostnameVerifier +-dontwarn org.openjsse.javax.net.ssl.SSLParameters +-dontwarn org.openjsse.javax.net.ssl.SSLSocket +-dontwarn org.openjsse.net.ssl.OpenJSSE + +# Fix for Retrofit issue https://github.com/square/retrofit/issues/3751 +# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items). +-keep,allowobfuscation,allowshrinking interface retrofit2.Call +-keep,allowobfuscation,allowshrinking class retrofit2.Response + +# With R8 full mode generic signatures are stripped for classes that are not +# kept. Suspend functions are wrapped in continuations where the type argument +# is used. +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d3d9fc9..0a4ddd4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,26 +2,33 @@ + + + + android:exported="true"> + + diff --git a/app/src/main/java/com/wei/picquest/MainActivity.kt b/app/src/main/java/com/wei/picquest/MainActivity.kt index 24fe677..ce186b5 100644 --- a/app/src/main/java/com/wei/picquest/MainActivity.kt +++ b/app/src/main/java/com/wei/picquest/MainActivity.kt @@ -10,19 +10,19 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview -import com.wei.picquest.ui.theme.PicQuestTheme +import com.wei.picquest.core.designsystem.theme.PqTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { - PicQuestTheme { + PqTheme { // A surface container using the 'background' color from the theme Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background, ) { - Greeting("Android") + Greeting("PicQuest") } } } @@ -40,7 +40,7 @@ fun Greeting(name: String, modifier: Modifier = Modifier) { @Preview(showBackground = true) @Composable fun GreetingPreview() { - PicQuestTheme { - Greeting("Android") + PqTheme { + Greeting("PicQuest") } } diff --git a/app/src/main/java/com/wei/picquest/PqApplication.kt b/app/src/main/java/com/wei/picquest/PqApplication.kt new file mode 100644 index 0000000..e07879f --- /dev/null +++ b/app/src/main/java/com/wei/picquest/PqApplication.kt @@ -0,0 +1,17 @@ +package com.wei.picquest + +import android.app.Application +import dagger.hilt.android.HiltAndroidApp +import timber.log.Timber + +@HiltAndroidApp +class PqApplication : Application() { + + override fun onCreate() { + super.onCreate() + + if (BuildConfig.DEBUG) { + Timber.plant(Timber.DebugTree()) + } + } +} diff --git a/app/src/main/java/com/wei/picquest/ui/theme/Color.kt b/app/src/main/java/com/wei/picquest/ui/theme/Color.kt deleted file mode 100644 index c87d8ae..0000000 --- a/app/src/main/java/com/wei/picquest/ui/theme/Color.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.wei.picquest.ui.theme - -import androidx.compose.ui.graphics.Color - -val Purple80 = Color(0xFFD0BCFF) -val PurpleGrey80 = Color(0xFFCCC2DC) -val Pink80 = Color(0xFFEFB8C8) - -val Purple40 = Color(0xFF6650a4) -val PurpleGrey40 = Color(0xFF625b71) -val Pink40 = Color(0xFF7D5260) diff --git a/app/src/main/java/com/wei/picquest/ui/theme/Theme.kt b/app/src/main/java/com/wei/picquest/ui/theme/Theme.kt deleted file mode 100644 index b3e2be8..0000000 --- a/app/src/main/java/com/wei/picquest/ui/theme/Theme.kt +++ /dev/null @@ -1,70 +0,0 @@ -package com.wei.picquest.ui.theme - -import android.app.Activity -import android.os.Build -import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.darkColorScheme -import androidx.compose.material3.dynamicDarkColorScheme -import androidx.compose.material3.dynamicLightColorScheme -import androidx.compose.material3.lightColorScheme -import androidx.compose.runtime.Composable -import androidx.compose.runtime.SideEffect -import androidx.compose.ui.graphics.toArgb -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalView -import androidx.core.view.WindowCompat - -private val DarkColorScheme = darkColorScheme( - primary = Purple80, - secondary = PurpleGrey80, - tertiary = Pink80, -) - -private val LightColorScheme = lightColorScheme( - primary = Purple40, - secondary = PurpleGrey40, - tertiary = Pink40, - - /* Other default colors to override - background = Color(0xFFFFFBFE), - surface = Color(0xFFFFFBFE), - onPrimary = Color.White, - onSecondary = Color.White, - onTertiary = Color.White, - onBackground = Color(0xFF1C1B1F), - onSurface = Color(0xFF1C1B1F), - */ -) - -@Composable -fun PicQuestTheme( - darkTheme: Boolean = isSystemInDarkTheme(), - // Dynamic color is available on Android 12+ - dynamicColor: Boolean = true, - content: @Composable () -> Unit, -) { - val colorScheme = when { - dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { - val context = LocalContext.current - if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) - } - - darkTheme -> DarkColorScheme - else -> LightColorScheme - } - val view = LocalView.current - if (!view.isInEditMode) { - SideEffect { - val window = (view.context as Activity).window - window.statusBarColor = colorScheme.primary.toArgb() - WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme - } - } - - MaterialTheme( - colorScheme = colorScheme, - typography = Typography, - content = content, - ) -} diff --git a/app/src/main/java/com/wei/picquest/ui/theme/Type.kt b/app/src/main/java/com/wei/picquest/ui/theme/Type.kt deleted file mode 100644 index e0ecbb4..0000000 --- a/app/src/main/java/com/wei/picquest/ui/theme/Type.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.wei.picquest.ui.theme - -import androidx.compose.material3.Typography -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontWeight -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, - ), - /* Other default text styles to override - titleLarge = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 22.sp, - lineHeight = 28.sp, - letterSpacing = 0.sp - ), - labelSmall = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Medium, - fontSize = 11.sp, - lineHeight = 16.sp, - letterSpacing = 0.5.sp - ) - */ -) diff --git a/app/src/main/res/drawable/ic_splash.xml b/app/src/main/res/drawable/ic_splash.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_splash.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml new file mode 100644 index 0000000..3e8d70b --- /dev/null +++ b/app/src/main/res/values-night/colors.xml @@ -0,0 +1,5 @@ + + + #FCFCFC + #000000 + diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..5e83fb3 --- /dev/null +++ b/app/src/main/res/values-night/themes.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f8c6127..be71fcc 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,10 +1,8 @@ - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file + + #4D000000 + + #000000 + #FCFCFC + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index d8c2e94..58046e0 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,5 +1,20 @@ - - + + + + + + -