-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 1주차 미션_레몬 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| *.iml | ||
| .gradle | ||
| /local.properties | ||
| /.idea/caches | ||
| /.idea/libraries | ||
| /.idea/modules.xml | ||
| /.idea/workspace.xml | ||
| /.idea/navEditor.xml | ||
| /.idea/assetWizardSettings.xml | ||
| .DS_Store | ||
| /build | ||
| /captures | ||
| .externalNativeBuild | ||
| .cxx | ||
| local.properties |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| plugins { | ||
| alias(libs.plugins.android.application) | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.example.week1" | ||
| compileSdk { | ||
| version = release(36) { | ||
| minorApiLevel = 1 | ||
| } | ||
| } | ||
|
|
||
| defaultConfig { | ||
| applicationId = "com.example.week1" | ||
| 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 | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.androidx.core.ktx) | ||
| implementation(libs.androidx.appcompat) | ||
| implementation(libs.material) | ||
| implementation(libs.androidx.activity) | ||
| implementation(libs.androidx.constraintlayout) | ||
| testImplementation(libs.junit) | ||
| androidTestImplementation(libs.androidx.junit) | ||
| androidTestImplementation(libs.androidx.espresso.core) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.example.week1 | ||
|
|
||
| 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.week1", appContext.packageName) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools"> | ||
|
|
||
| <application | ||
| android:allowBackup="true" | ||
| android:dataExtractionRules="@xml/data_extraction_rules" | ||
| android:fullBackupContent="@xml/backup_rules" | ||
| android:icon="@mipmap/ic_launcher" | ||
| android:label="@string/app_name" | ||
| android:roundIcon="@mipmap/ic_launcher_round" | ||
| android:supportsRtl="true" | ||
| android:theme="@style/Theme.Week1"> | ||
| <activity | ||
| android:name=".MainActivity" | ||
| android:exported="true"> | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN" /> | ||
|
|
||
| <category android:name="android.intent.category.LAUNCHER" /> | ||
| </intent-filter> | ||
| </activity> | ||
| </application> | ||
|
|
||
| </manifest> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package com.example.week1 | ||
|
|
||
| import android.os.Bundle | ||
| import androidx.activity.enableEdgeToEdge | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import androidx.core.view.ViewCompat | ||
| import androidx.core.view.WindowInsetsCompat | ||
| import android.widget.TextView | ||
| import android.widget.ImageView | ||
| import android.graphics.Color | ||
|
|
||
| class MainActivity : AppCompatActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| enableEdgeToEdge() | ||
| setContentView(R.layout.activity_main) | ||
| val text1 : TextView = findViewById<TextView>(R.id.text1) | ||
| val text2 : TextView = findViewById<TextView>(R.id.text2) | ||
| val text3 : TextView = findViewById<TextView>(R.id.text3) | ||
| val text4 : TextView = findViewById<TextView>(R.id.text4) | ||
| val text5 : TextView = findViewById<TextView>(R.id.text5) | ||
| val good : ImageView = findViewById<ImageView>(R.id.good) | ||
| val happy : ImageView = findViewById<ImageView>(R.id.happy) | ||
| val soso : ImageView = findViewById<ImageView>(R.id.soso) | ||
| val bad : ImageView = findViewById<ImageView>(R.id.bad) | ||
| val angry : ImageView = findViewById<ImageView>(R.id.angry) | ||
|
|
||
| fun resetTextColors() { | ||
| text1.setTextColor(Color.BLACK) | ||
| text2.setTextColor(Color.BLACK) | ||
| text3.setTextColor(Color.BLACK) | ||
| text4.setTextColor(Color.BLACK) | ||
| text5.setTextColor(Color.BLACK) | ||
| } | ||
|
|
||
| good.setOnClickListener { | ||
| resetTextColors() | ||
| text1.setTextColor(Color.parseColor("#F9DC77")) | ||
| } | ||
|
Comment on lines
+36
to
+39
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Color.parseColor("#F9DC77") 같은 값들이 하드코딩되어 있습니다 |
||
|
|
||
| happy.setOnClickListener { | ||
| resetTextColors() | ||
| text2.setTextColor(Color.parseColor("#AEE9FE")) | ||
| } | ||
|
|
||
| soso.setOnClickListener { | ||
| resetTextColors() | ||
| text3.setTextColor(Color.parseColor("#94A5FE")) | ||
| } | ||
|
|
||
| bad.setOnClickListener { | ||
| resetTextColors() | ||
| text4.setTextColor(Color.parseColor("#77C48D")) | ||
| } | ||
|
|
||
| angry.setOnClickListener { | ||
| resetTextColors() | ||
| text5.setTextColor(Color.parseColor("#D94F49")) | ||
| } | ||
|
|
||
| ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> | ||
| val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) | ||
| v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) | ||
| insets | ||
| } | ||
| } | ||
|
Comment on lines
+61
to
+66
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 ViewCompat.setOnApplyWindowInsetsListener 코드가 맨 아래에 위치해 있는데요! 이 코드는 상태바나 네비게이션 바 등 시스템 UI 영역의 여백을 잡아주는 기초 공사 역할을 합니다. 보통 onCreate 내부의 코드는 아래와 같은 흐름으로 배치하면 읽기가 훨씬 수월해집니다. 예를 들어서 1단계: 기본 설정 및 화면 연결 (super.onCreate, setContentView) 2단계: 화면 여백 및 시스템 UI 설정 (WindowInsetsListener) 3단계: 뷰 초기화 (ViewBinding 초기화) 4단계: 이벤트 리스너 등록 (setOnClickListener 등) 따라서 WindowInsets 코드를 setContentView 바로 아래쪽으로 올려주시면 구조가 훨씬 깔끔해질 것 같습니다! |
||
|
|
||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR 사진을 보니 happy.png, good.png 처럼 이미지 파일명과 포맷을 그대로 사용하신 것 같아요! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
|
||
| <path android:fillColor="@android:color/white" android:pathData="M11.67,3.87L9.9,2.1 0,12l9.9,9.9 1.77,-1.77L3.54,12z"/> | ||
|
|
||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="108dp" | ||
| android:height="108dp" | ||
| android:viewportWidth="108" | ||
| android:viewportHeight="108"> | ||
| <path | ||
| android:fillColor="#3DDC84" | ||
| android:pathData="M0,0h108v108h-108z" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M9,0L9,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M19,0L19,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M29,0L29,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M39,0L39,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M49,0L49,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M59,0L59,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M69,0L69,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M79,0L79,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M89,0L89,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M99,0L99,108" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,9L108,9" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,19L108,19" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,29L108,29" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,39L108,39" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,49L108,49" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,59L108,59" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,69L108,69" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,79L108,79" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,89L108,89" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M0,99L108,99" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M19,29L89,29" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M19,39L89,39" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M19,49L89,49" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M19,59L89,59" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M19,69L89,69" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M19,79L89,79" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M29,19L29,89" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M39,19L39,89" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M49,19L49,89" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M59,19L59,89" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M69,19L69,89" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| <path | ||
| android:fillColor="#00000000" | ||
| android:pathData="M79,19L79,89" | ||
| android:strokeWidth="0.8" | ||
| android:strokeColor="#33FFFFFF" /> | ||
| </vector> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MainActivity를 보면 findViewById가 10번이나 반복되고 있습니다. 요즘 안드로이드 개발에서는 뷰 바인딩(View Binding)을 도입해서 이런 보일러플레이트 코드를 줄이고 Null 안정성을 챙기는 추세입니다! 다음 미션 때 꼭 한번 적용해 보시는 걸 추천해요!