diff --git a/Tutorial_03/.gitignore b/Tutorial_03/.gitignore new file mode 100644 index 0000000..e301d78 --- /dev/null +++ b/Tutorial_03/.gitignore @@ -0,0 +1,131 @@ +## Seb's .gitignore template +# You can find the most up-to-date version at https://go.sebastiano.dev/gitignore +# Partly based on templates by https://plugins.jetbrains.com/plugin/7495--ignore +# Released under a CC-0 License https://creativecommons.org/share-your-work/public-domain/cc0/ + +### Windows template +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### macOS template +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Linux template +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +*.iml +*.ipr +*.iws +/.idea/* + +# Exclude non-user-specific stuff +!.idea/.name +!.idea/codeInsightSettings.xml +!.idea/codeStyles/ +!.idea/copyright/ +!.idea/dataSources.xml +!.idea/detekt.xml +!.idea/encodings.xml +!.idea/externalDependencies.xml +!.idea/file.template.settings.xml +!.idea/fileTemplates/ +!.idea/icon.svg +!.idea/inspectionProfiles/ +!.idea/runConfigurations/ +!.idea/scopes/ +!.idea/vcs.xml + +### Kotlin template +# Compiled class file +*.class + +# Log file +*.log + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Gradle template +.gradle + +# Note that you may need to exclude by hand other folders +# named build if necessary (e.g., in src/) +**/build/ + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle/wrapper/gradle-wrapper.jar + +# Cache of project +.gradletasknamecache diff --git a/Tutorial_03/.idea/.name b/Tutorial_03/.idea/.name new file mode 100644 index 0000000..2ab37f8 --- /dev/null +++ b/Tutorial_03/.idea/.name @@ -0,0 +1 @@ +03_code \ No newline at end of file diff --git a/Tutorial_03/.idea/vcs.xml b/Tutorial_03/.idea/vcs.xml new file mode 100644 index 0000000..f245aa7 --- /dev/null +++ b/Tutorial_03/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Tutorial_03/README.md b/Tutorial_03/README.md new file mode 100644 index 0000000..6b99ead --- /dev/null +++ b/Tutorial_03/README.md @@ -0,0 +1 @@ +각자 작업하신거 `./{LectureName}/` 폴더 만드시고 PR해주세요 \ No newline at end of file diff --git a/Tutorial_03/app/.gitignore b/Tutorial_03/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/Tutorial_03/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/Tutorial_03/app/build.gradle.kts b/Tutorial_03/app/build.gradle.kts new file mode 100644 index 0000000..61dcbc8 --- /dev/null +++ b/Tutorial_03/app/build.gradle.kts @@ -0,0 +1,50 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) +} + +android { + namespace = "com.example.swpp.cloud_code" + compileSdk = 36 + + defaultConfig { + applicationId = "com.example.swpp.cloud_code" + minSdk = 24 + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } +} + +dependencies { + + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.material) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + + implementation("com.squareup.retrofit2:retrofit:2.9.0") + implementation("com.google.code.gson:gson:2.8.9") + implementation("com.squareup.retrofit2:converter-gson:2.4.0") +} \ No newline at end of file diff --git a/Tutorial_03/app/proguard-rules.pro b/Tutorial_03/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/Tutorial_03/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/Tutorial_03/app/src/androidTest/java/com/example/swpp/cloud_code/ExampleInstrumentedTest.kt b/Tutorial_03/app/src/androidTest/java/com/example/swpp/cloud_code/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..7c2ebb5 --- /dev/null +++ b/Tutorial_03/app/src/androidTest/java/com/example/swpp/cloud_code/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.swpp.cloud_code + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.example.swpp.cloud_code", appContext.packageName) + } +} \ No newline at end of file diff --git a/Tutorial_03/app/src/main/AndroidManifest.xml b/Tutorial_03/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..01d3fef --- /dev/null +++ b/Tutorial_03/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/CodeMessageResponse.kt b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/CodeMessageResponse.kt new file mode 100644 index 0000000..5666a34 --- /dev/null +++ b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/CodeMessageResponse.kt @@ -0,0 +1,11 @@ +package com.example.swpp.cloud_code + +import com.google.gson.annotations.SerializedName + +data class CodeMessageResponse( + @SerializedName("code") + val code: Int, + + @SerializedName("message") + val message: String +) diff --git a/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/MainActivity.kt b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/MainActivity.kt new file mode 100644 index 0000000..6e4f996 --- /dev/null +++ b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/MainActivity.kt @@ -0,0 +1,59 @@ +package com.example.swpp.cloud_code + +import android.os.Bundle +import android.widget.Button +import android.widget.TextView +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response + +class MainActivity : AppCompatActivity() { + + private lateinit var nameInput: TextView + private lateinit var idInput: TextView + private lateinit var writeButton: Button + private lateinit var targetNameInput: TextView + private lateinit var readButton: Button + private lateinit var targetNameOutput: TextView + private lateinit var idText: TextView + + private lateinit var service: ServiceApi + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + nameInput = findViewById(R.id.NameInput) + idInput = findViewById(R.id.IdInput) + writeButton = findViewById(R.id.WriteBtn) + targetNameInput = findViewById(R.id.TargetNameInput) + readButton = findViewById(R.id.ReadBtn) + targetNameOutput = findViewById(R.id.TargetNameOutput) + idText = findViewById(R.id.IdOutput) + + service = RetrofitClient.getClient().create(ServiceApi::class.java) + + writeButton.setOnClickListener { + val userName = nameInput.text.toString() + val userId = idInput.text.toString() + + val requestData = NameIdData(userName, userId) + + service.userWrite(requestData).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + val result = response.body() + Toast.makeText(this@MainActivity, result?.message, Toast.LENGTH_SHORT).show() + } + + override fun onFailure(call: Call, t: Throwable) { + Toast.makeText(this@MainActivity, "Write Error", Toast.LENGTH_SHORT).show() + } + }) + } + } +} \ No newline at end of file diff --git a/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/NameIdData.kt b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/NameIdData.kt new file mode 100644 index 0000000..7fda75c --- /dev/null +++ b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/NameIdData.kt @@ -0,0 +1,11 @@ +package com.example.swpp.cloud_code + +import com.google.gson.annotations.SerializedName + +data class NameIdData( + @SerializedName("userName") + val userName: String, + + @SerializedName("userId") + val userId: String +) diff --git a/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/RetrofitClient.kt b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/RetrofitClient.kt new file mode 100644 index 0000000..87f49bf --- /dev/null +++ b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/RetrofitClient.kt @@ -0,0 +1,20 @@ +package com.example.swpp.cloud_code + +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory + +object RetrofitClient { + private const val BASE_URL = "http://ec2-16-184-15-144.ap-northeast-2.compute.amazonaws.com:3000" // TODO: Replace with your actual EC2 endpoint + + private var retrofit: Retrofit? = null + + fun getClient(): Retrofit { + if (retrofit == null) { + retrofit = Retrofit.Builder() + .baseUrl(BASE_URL) + .addConverterFactory(GsonConverterFactory.create()) + .build() + } + return retrofit!! + } +} \ No newline at end of file diff --git a/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/ServiceApi.kt b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/ServiceApi.kt new file mode 100644 index 0000000..bf12cdc --- /dev/null +++ b/Tutorial_03/app/src/main/java/com/example/swpp/cloud_code/ServiceApi.kt @@ -0,0 +1,10 @@ +package com.example.swpp.cloud_code + +import retrofit2.Call +import retrofit2.http.Body +import retrofit2.http.POST + +interface ServiceApi { + @POST("/user/write") + fun userWrite(@Body data: NameIdData): Call +} diff --git a/Tutorial_03/app/src/main/res/drawable/btn_bg.xml b/Tutorial_03/app/src/main/res/drawable/btn_bg.xml new file mode 100644 index 0000000..5ff570b --- /dev/null +++ b/Tutorial_03/app/src/main/res/drawable/btn_bg.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/drawable/edittext_bg.xml b/Tutorial_03/app/src/main/res/drawable/edittext_bg.xml new file mode 100644 index 0000000..5250d9a --- /dev/null +++ b/Tutorial_03/app/src/main/res/drawable/edittext_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/drawable/edittext_focused.xml b/Tutorial_03/app/src/main/res/drawable/edittext_focused.xml new file mode 100644 index 0000000..a1e93f6 --- /dev/null +++ b/Tutorial_03/app/src/main/res/drawable/edittext_focused.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/drawable/edittext_unfocused.xml b/Tutorial_03/app/src/main/res/drawable/edittext_unfocused.xml new file mode 100644 index 0000000..99b3b41 --- /dev/null +++ b/Tutorial_03/app/src/main/res/drawable/edittext_unfocused.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/drawable/ic_launcher_background.xml b/Tutorial_03/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/Tutorial_03/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tutorial_03/app/src/main/res/drawable/ic_launcher_foreground.xml b/Tutorial_03/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/Tutorial_03/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/layout/activity_main.xml b/Tutorial_03/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..42c6e9c --- /dev/null +++ b/Tutorial_03/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/Tutorial_03/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/Tutorial_03/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/Tutorial_03/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/Tutorial_03/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/Tutorial_03/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/Tutorial_03/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/Tutorial_03/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/Tutorial_03/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/Tutorial_03/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/Tutorial_03/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/Tutorial_03/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/Tutorial_03/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/Tutorial_03/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/Tutorial_03/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/Tutorial_03/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/Tutorial_03/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/Tutorial_03/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/Tutorial_03/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/Tutorial_03/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/Tutorial_03/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/Tutorial_03/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/Tutorial_03/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/Tutorial_03/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/Tutorial_03/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/Tutorial_03/app/src/main/res/values/colors.xml b/Tutorial_03/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..c8524cd --- /dev/null +++ b/Tutorial_03/app/src/main/res/values/colors.xml @@ -0,0 +1,5 @@ + + + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/values/strings.xml b/Tutorial_03/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..680f78f --- /dev/null +++ b/Tutorial_03/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + CloudComputingTutorial + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/values/styles.xml b/Tutorial_03/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..a11a04e --- /dev/null +++ b/Tutorial_03/app/src/main/res/values/styles.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tutorial_03/app/src/main/res/values/themes.xml b/Tutorial_03/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..fbef2e5 --- /dev/null +++ b/Tutorial_03/app/src/main/res/values/themes.xml @@ -0,0 +1,9 @@ + + + + +