Skip to content

Commit 54174d1

Browse files
committed
week1 코틀린 실습
1 parent 5f34c29 commit 54174d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+620
-18
lines changed

jm/.idea/gradle.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jm/app/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ dependencies {
4848
testImplementation("junit:junit:4.13.2")
4949
androidTestImplementation("androidx.test.ext:junit:1.1.5")
5050
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
51-
}
51+
}
52+

jm/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
plugins {
33
id("com.android.application") version "8.1.1" apply false
44
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
5-
}
5+
6+
}

jm/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ dependencyResolutionManagement {
1515

1616
rootProject.name = "jm"
1717
include(":app")
18-
include(":week1")
18+
include(":week_1")

jm/week1/build.gradle.kts

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ android {
1515
versionName = "1.0"
1616

1717
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18+
vectorDrawables {
19+
useSupportLibrary = true
20+
}
1821
}
1922

2023
buildTypes {
@@ -33,15 +36,48 @@ android {
3336
kotlinOptions {
3437
jvmTarget = "1.8"
3538
}
39+
buildFeatures {
40+
compose = true
41+
}
42+
composeOptions {
43+
kotlinCompilerExtensionVersion = "1.4.3"
44+
}
45+
packaging {
46+
resources {
47+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
48+
}
49+
}
3650
}
3751

3852
dependencies {
3953

4054
implementation("androidx.core:core-ktx:1.9.0")
41-
implementation("androidx.appcompat:appcompat:1.6.1")
42-
implementation("com.google.android.material:material:1.9.0")
43-
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
55+
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
56+
implementation("androidx.activity:activity-compose:1.7.2")
57+
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
58+
implementation("androidx.compose.ui:ui")
59+
implementation("androidx.compose.ui:ui-graphics")
60+
implementation("androidx.compose.ui:ui-tooling-preview")
61+
implementation("androidx.compose.material3:material3")
4462
testImplementation("junit:junit:4.13.2")
4563
androidTestImplementation("androidx.test.ext:junit:1.1.5")
4664
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
65+
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
66+
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
67+
debugImplementation("androidx.compose.ui:ui-tooling")
68+
debugImplementation("androidx.compose.ui:ui-test-manifest")
69+
}
70+
71+
android {
72+
buildFeatures {
73+
compose = true
74+
}
75+
76+
composeOptions {
77+
kotlinCompilerExtensionVersion = "1.4.3"
78+
}
79+
80+
kotlinOptions {
81+
jvmTarget = "1.8"
82+
}
4783
}

jm/week1/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
android:theme="@style/Theme.Jm">
1111
<activity
1212
android:name=".MainActivity"
13-
android:exported="true">
13+
android:exported="true"
14+
android:label="@string/app_name"
15+
android:theme="@style/Theme.Jm">
1416
<intent-filter>
1517
<action android:name="android.intent.action.MAIN" />
1618

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,46 @@
11
package com.example.week1
22

3-
import androidx.appcompat.app.AppCompatActivity
43
import android.os.Bundle
4+
import androidx.activity.ComponentActivity
5+
import androidx.activity.compose.setContent
6+
import androidx.compose.foundation.layout.fillMaxSize
7+
import androidx.compose.material3.MaterialTheme
8+
import androidx.compose.material3.Surface
9+
import androidx.compose.material3.Text
10+
import androidx.compose.runtime.Composable
11+
import androidx.compose.ui.Modifier
12+
import androidx.compose.ui.tooling.preview.Preview
13+
import com.example.week1.ui.theme.JmTheme
514

6-
class MainActivity : AppCompatActivity() {
15+
class MainActivity : ComponentActivity() {
716
override fun onCreate(savedInstanceState: Bundle?) {
817
super.onCreate(savedInstanceState)
9-
setContentView(R.layout.activity_main)
18+
setContent {
19+
JmTheme {
20+
// A surface container using the 'background' color from the theme
21+
Surface(
22+
modifier = Modifier.fillMaxSize(),
23+
color = MaterialTheme.colorScheme.background
24+
) {
25+
Greeting("Android")
26+
}
27+
}
28+
}
29+
}
30+
}
31+
32+
@Composable
33+
fun Greeting(name: String, modifier: Modifier = Modifier) {
34+
Text(
35+
text = "Hello $name!",
36+
modifier = modifier
37+
)
38+
}
39+
40+
@Preview(showBackground = true)
41+
@Composable
42+
fun GreetingPreview() {
43+
JmTheme {
44+
Greeting("Android")
1045
}
1146
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.week1
2+
3+
fun main() {
4+
var input = readLine()!!.split(" ")
5+
var A = input[0].toInt()
6+
var B = input[1].toInt()
7+
8+
println(A+B)
9+
println(A-B)
10+
println(A*B)
11+
println(A/B)
12+
println(A%B)
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.example.week1.ui.theme
2+
3+
import androidx.compose.ui.graphics.Color
4+
5+
val Purple80 = Color(0xFFD0BCFF)
6+
val PurpleGrey80 = Color(0xFFCCC2DC)
7+
val Pink80 = Color(0xFFEFB8C8)
8+
9+
val Purple40 = Color(0xFF6650a4)
10+
val PurpleGrey40 = Color(0xFF625b71)
11+
val Pink40 = Color(0xFF7D5260)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.example.week1.ui.theme
2+
3+
import android.app.Activity
4+
import android.os.Build
5+
import androidx.compose.foundation.isSystemInDarkTheme
6+
import androidx.compose.material3.MaterialTheme
7+
import androidx.compose.material3.darkColorScheme
8+
import androidx.compose.material3.dynamicDarkColorScheme
9+
import androidx.compose.material3.dynamicLightColorScheme
10+
import androidx.compose.material3.lightColorScheme
11+
import androidx.compose.runtime.Composable
12+
import androidx.compose.runtime.SideEffect
13+
import androidx.compose.ui.graphics.toArgb
14+
import androidx.compose.ui.platform.LocalContext
15+
import androidx.compose.ui.platform.LocalView
16+
import androidx.core.view.WindowCompat
17+
18+
private val DarkColorScheme = darkColorScheme(
19+
primary = Purple80,
20+
secondary = PurpleGrey80,
21+
tertiary = Pink80
22+
)
23+
24+
private val LightColorScheme = lightColorScheme(
25+
primary = Purple40,
26+
secondary = PurpleGrey40,
27+
tertiary = Pink40
28+
29+
/* Other default colors to override
30+
background = Color(0xFFFFFBFE),
31+
surface = Color(0xFFFFFBFE),
32+
onPrimary = Color.White,
33+
onSecondary = Color.White,
34+
onTertiary = Color.White,
35+
onBackground = Color(0xFF1C1B1F),
36+
onSurface = Color(0xFF1C1B1F),
37+
*/
38+
)
39+
40+
@Composable
41+
fun JmTheme(
42+
darkTheme: Boolean = isSystemInDarkTheme(),
43+
// Dynamic color is available on Android 12+
44+
dynamicColor: Boolean = true,
45+
content: @Composable () -> Unit
46+
) {
47+
val colorScheme = when {
48+
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
49+
val context = LocalContext.current
50+
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
51+
}
52+
53+
darkTheme -> DarkColorScheme
54+
else -> LightColorScheme
55+
}
56+
val view = LocalView.current
57+
if (!view.isInEditMode) {
58+
SideEffect {
59+
val window = (view.context as Activity).window
60+
window.statusBarColor = colorScheme.primary.toArgb()
61+
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
62+
}
63+
}
64+
65+
MaterialTheme(
66+
colorScheme = colorScheme,
67+
typography = Typography,
68+
content = content
69+
)
70+
}

0 commit comments

Comments
 (0)