diff --git a/.gitignore b/.gitignore index aa724b7..4832baa 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,8 @@ .externalNativeBuild .cxx local.properties + +/.idea/misc.xml +/.idea/gradle.xml +/.idea/compiler.xml +/.idea/.name diff --git a/.idea/.gitignore b/.idea/.gitignore index 26d3352..aff6f92 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,3 +1,4 @@ # Default ignored files /shelf/ /workspace.xml +/vcs.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index aa39fe5..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Android Test \ No newline at end of file diff --git a/.idea/appInsightsSettings.xml b/.idea/appInsightsSettings.xml deleted file mode 100644 index 145bb1c..0000000 --- a/.idea/appInsightsSettings.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index b589d56..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 0c0c338..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 9f47dfb..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 44ca2d9..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index fdf8d99..0000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml deleted file mode 100644 index f8051a6..0000000 --- a/.idea/migrations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 8978d23..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cee76ae..57271a6 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,19 +1,18 @@ -@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed plugins { - alias(libs.plugins.androidApplication) - alias(libs.plugins.kotlinAndroid) + id("shindra.application") + id("shindra.application.compose") + id("shindra.hilt") } + android { - namespace = "com.example.androidtest" - compileSdk = 34 + namespace = "com.shindra.chargemap" + defaultConfig { - applicationId = "com.example.androidtest" - minSdk = 23 - targetSdk = 34 + applicationId = "com.shindra.chargemap" versionCode = 1 - versionName = "1.0" + versionName = "1.0.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { @@ -22,49 +21,51 @@ android { } buildTypes { - release { - isMinifyEnabled = false + val debug by getting { + applicationIdSuffix = ".debug" + } + + val release by getting { + isMinifyEnabled = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) + + // 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") } } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = "1.8" - } - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = "1.5.1" - } + packaging { resources { - excludes += "/META-INF/{AL2.0,LGPL2.1}" + excludes.add("/META-INF/{AL2.0,LGPL2.1}") } } } dependencies { + implementation(project(":core:designsystem")) + implementation(project(":feature:planes")) + implementation(project(":feature:planeDetails")) + + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.lifecycle.runtimeCompose) + implementation(libs.androidx.compose.material3.windowSizeClass) + implementation(libs.androidx.hilt.navigation.compose) + implementation(libs.androidx.navigation.compose) + + implementation(libs.coil.kt) + implementation(libs.coil.kt.svg) + + testImplementation(libs.junit4) + androidTestImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.espresso.core) - implementation(libs.core.ktx) - implementation(libs.lifecycle.runtime.ktx) - implementation(libs.activity.compose) - implementation(platform(libs.compose.bom)) - implementation(libs.ui) - implementation(libs.ui.graphics) - implementation(libs.ui.tooling.preview) - implementation(libs.material3) - testImplementation(libs.junit) - androidTestImplementation(libs.androidx.test.ext.junit) - androidTestImplementation(libs.espresso.core) - androidTestImplementation(platform(libs.compose.bom)) - androidTestImplementation(libs.ui.test.junit4) - debugImplementation(libs.ui.tooling) - debugImplementation(libs.ui.test.manifest) } \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..ff59496 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 diff --git a/app/src/androidTest/java/com/example/androidtest/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/shindra/chargemap/ExampleInstrumentedTest.kt similarity index 84% rename from app/src/androidTest/java/com/example/androidtest/ExampleInstrumentedTest.kt rename to app/src/androidTest/java/com/shindra/chargemap/ExampleInstrumentedTest.kt index faf9720..1320dad 100644 --- a/app/src/androidTest/java/com/example/androidtest/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/com/shindra/chargemap/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package com.example.androidtest +package com.shindra.chargemap import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -19,6 +19,6 @@ class ExampleInstrumentedTest { fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.example.androidtest", appContext.packageName) + assertEquals("com.shindra.chargemap", appContext.packageName) } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fd88cc2..37242bc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,21 +2,23 @@ + + + + android:theme="@style/Theme.ChargeMap"> diff --git a/app/src/main/java/com/example/androidtest/MainActivity.kt b/app/src/main/java/com/example/androidtest/MainActivity.kt deleted file mode 100644 index 8fa2b80..0000000 --- a/app/src/main/java/com/example/androidtest/MainActivity.kt +++ /dev/null @@ -1,46 +0,0 @@ -package com.example.androidtest - -import android.os.Bundle -import androidx.activity.ComponentActivity -import androidx.activity.compose.setContent -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview -import com.example.androidtest.ui.theme.AndroidTestTheme - -class MainActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - AndroidTestTheme { - // A surface container using the 'background' color from the theme - Surface( - modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background - ) { - Greeting("Android") - } - } - } - } -} - -@Composable -fun Greeting(name: String, modifier: Modifier = Modifier) { - Text( - text = "Hello $name!", - modifier = modifier - ) -} - -@Preview(showBackground = true) -@Composable -fun GreetingPreview() { - AndroidTestTheme { - Greeting("Android") - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/androidtest/ui/theme/Color.kt b/app/src/main/java/com/example/androidtest/ui/theme/Color.kt deleted file mode 100644 index 8a10bf4..0000000 --- a/app/src/main/java/com/example/androidtest/ui/theme/Color.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.androidtest.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) \ No newline at end of file diff --git a/app/src/main/java/com/example/androidtest/ui/theme/Theme.kt b/app/src/main/java/com/example/androidtest/ui/theme/Theme.kt deleted file mode 100644 index 027c97f..0000000 --- a/app/src/main/java/com/example/androidtest/ui/theme/Theme.kt +++ /dev/null @@ -1,70 +0,0 @@ -package com.example.androidtest.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 AndroidTestTheme( - 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 - ) -} \ No newline at end of file diff --git a/app/src/main/java/com/shindra/chargemap/ChargeMapApplication.kt b/app/src/main/java/com/shindra/chargemap/ChargeMapApplication.kt new file mode 100644 index 0000000..7c822eb --- /dev/null +++ b/app/src/main/java/com/shindra/chargemap/ChargeMapApplication.kt @@ -0,0 +1,7 @@ +package com.shindra.chargemap + +import android.app.Application +import dagger.hilt.android.HiltAndroidApp + +@HiltAndroidApp +class ChargeMapApplication : Application() diff --git a/app/src/main/java/com/shindra/chargemap/MainActivity.kt b/app/src/main/java/com/shindra/chargemap/MainActivity.kt new file mode 100644 index 0000000..200b1a4 --- /dev/null +++ b/app/src/main/java/com/shindra/chargemap/MainActivity.kt @@ -0,0 +1,20 @@ +package com.shindra.chargemap + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import com.shindra.chargemap.ui.ChargeMapApp +import com.shindra.chargemap.core.designsystem.theme.ChargeMapTheme +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + ChargeMapTheme { + ChargeMapApp() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/shindra/chargemap/navigation/ChargeMapNavhost.kt b/app/src/main/java/com/shindra/chargemap/navigation/ChargeMapNavhost.kt new file mode 100644 index 0000000..4e4f7a5 --- /dev/null +++ b/app/src/main/java/com/shindra/chargemap/navigation/ChargeMapNavhost.kt @@ -0,0 +1,37 @@ +package com.shindra.chargemap.navigation + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import com.shindra.chargemap.feature.planedetails.navigation.navigateToPlaneDetails +import com.shindra.chargemap.feature.planedetails.navigation.planeDetails +import com.shindra.chargemap.feature.planes.navigation.planesScreen +import com.shindra.chargemap.feature.planes.navigation.planesScreenRouteId + + +@Composable +fun ChargeMapNavHost( + navController: NavHostController, + modifier: Modifier = Modifier, + startDestination: String = planesScreenRouteId, + onTitleChange: (String) -> Unit +) { + NavHost( + navController = navController, + startDestination = startDestination, + modifier = modifier, + ) { + planesScreen( + onTitleChange = onTitleChange, + onMassAndBalanceClick = { manufacturer, model -> + navController.navigateToPlaneDetails( + manufacturer = manufacturer, + model = model + ) + } + ) + + planeDetails(onTitleChange) + } +} diff --git a/app/src/main/java/com/shindra/chargemap/ui/ChargeMapApp.kt b/app/src/main/java/com/shindra/chargemap/ui/ChargeMapApp.kt new file mode 100644 index 0000000..6b99e40 --- /dev/null +++ b/app/src/main/java/com/shindra/chargemap/ui/ChargeMapApp.kt @@ -0,0 +1,73 @@ +package com.shindra.chargemap.ui + +import androidx.compose.foundation.layout.padding +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material3.CenterAlignedTopAppBar +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.TopAppBarScrollBehavior +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import com.shindra.chargemap.navigation.ChargeMapNavHost + +@OptIn( + ExperimentalMaterial3Api::class, +) +@Composable +fun ChargeMapApp( + appState: ChargeMapAppState = rememberChargeMapAppState() +) { + var toolbarTitle by remember { mutableStateOf("") } + + Scaffold( + topBar = { + Toolbar( + title = toolbarTitle, + hasNavUp = appState.shouldShowNavUp, + onNavUpClick = { appState.navigateUp() } + ) + + } + ) { + ChargeMapNavHost( + modifier = Modifier.padding(it), + navController = appState.navController, + onTitleChange = { newTitle -> + toolbarTitle = newTitle + } + ) + } +} + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +private fun Toolbar( + title: String, + hasNavUp: Boolean, + onNavUpClick: () -> Unit, + scrollBehavior: TopAppBarScrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() +) { + CenterAlignedTopAppBar( + title = { Text(text = title) }, + navigationIcon = { + if (hasNavUp) { + IconButton(onClick = { onNavUpClick() }) { + Icon( + imageVector = Icons.Default.ArrowBack, + contentDescription = null + ) + } + } + }, + scrollBehavior = scrollBehavior + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/shindra/chargemap/ui/ChargeMapAppState.kt b/app/src/main/java/com/shindra/chargemap/ui/ChargeMapAppState.kt new file mode 100644 index 0000000..b6f6b57 --- /dev/null +++ b/app/src/main/java/com/shindra/chargemap/ui/ChargeMapAppState.kt @@ -0,0 +1,34 @@ +package com.shindra.chargemap.ui + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.navigation.NavDestination +import androidx.navigation.NavHostController +import androidx.navigation.compose.currentBackStackEntryAsState +import androidx.navigation.compose.rememberNavController +import com.shindra.chargemap.feature.planes.navigation.planesScreenRouteId + +@Composable +fun rememberChargeMapAppState( + navController: NavHostController = rememberNavController() +) = remember(navController) { + ChargeMapAppState(navController) +} + +class ChargeMapAppState(val navController: NavHostController) { + + val currentDestination: NavDestination? + @Composable get() = navController + .currentBackStackEntryAsState().value?.destination + + val shouldShowNavUp: Boolean + @Composable get() { + val cDestination = currentDestination?.route ?: return false + return cDestination != planesScreenRouteId + } + + fun navigateUp() { + navController.navigateUp() + } + +} \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index 6f3b755..eca70cf 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -2,5 +2,4 @@ - \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index 6f3b755..eca70cf 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -2,5 +2,4 @@ - \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa43411..604714e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - Android Test + ChargeMap - test \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index b28fc40..7c21160 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,5 +1,5 @@ -