Skip to content
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

[feat/number_picker]: 넘버 피커로 시간, 분 선택 뷰 샘플 구현 #21

Merged
merged 6 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ dependencies {
// Splash
implementation(libs.splash.screen)

implementation(projects.feature.onboarding)
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/hmh/hamyeonham/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.hmh.hamyeonham

import android.content.Intent
import android.os.Bundle
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.hmh.hamyeonham.feature.onboarding.OnBoardingActivity

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -15,6 +17,7 @@ class MainActivity : AppCompatActivity() {
initSplashAnimation(splashScreen)

setContentView(R.layout.activity_main)
Intent(this, OnBoardingActivity::class.java).let(::startActivity)
}

private fun initSplashAnimation(splashScreen: SplashScreen) {
Expand Down
1 change: 1 addition & 0 deletions feature/onboarding/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
12 changes: 12 additions & 0 deletions feature/onboarding/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
hmh("feature")
}

android {
namespace = "com.hmh.hamyeonham.feature.onboarding"
}

dependencies {
implementation(projects.core.common)
}
Empty file.
21 changes: 21 additions & 0 deletions feature/onboarding/proguard-rules.pro
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.hmh.hamyeonham.feature.onboarding

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.hmh.hamyeonham.feature.onboarding.test", appContext.packageName)
}
}
10 changes: 10 additions & 0 deletions feature/onboarding/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity
android:name=".OnBoardingActivity"
android:exported="false" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hmh.hamyeonham.feature.onboarding

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.hmh.hamyeonham.feature.onboarding.databinding.ActivityOnBoardingBinding

class OnBoardingActivity : AppCompatActivity() {
private lateinit var binding: ActivityOnBoardingBinding
override fun onCreate(savedInstanceState: Bundle?) {
binding = ActivityOnBoardingBinding.inflate(layoutInflater)
super.onCreate(savedInstanceState)
setContentView(binding.root)

binding.run {
numberPicker.npCustomHours.minValue = 1
numberPicker.npCustomHours.maxValue = 6
numberPicker.npCustomMinutes.minValue = 1
numberPicker.npCustomMinutes.maxValue = 59
}
}
}
16 changes: 16 additions & 0 deletions feature/onboarding/src/main/res/layout/activity_on_boarding.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".OnBoardingActivity">

<include
android:id="@+id/numberPicker"
layout="@layout/dialog_numberpicker_custom"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<NumberPicker
android:id="@+id/np_custom_hours"
android:layout_width="50dp"
android:layout_height="100dp"
android:theme="@style/AppTheme.NumberPicker"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="시간"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/np_custom_hours"
app:layout_constraintTop_toTopOf="parent"
/>

<NumberPicker
android:id="@+id/np_custom_minutes"
android:layout_width="50dp"
android:layout_height="100dp"
android:layout_marginHorizontal="50dp"
android:theme="@style/AppTheme.NumberPicker"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/np_custom_hours"
app:layout_constraintTop_toTopOf="parent"
android:scrollbarSize="20dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="분"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/np_custom_minutes"
app:layout_constraintTop_toTopOf="parent"
/>

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions feature/onboarding/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<resources></resources>
8 changes: 8 additions & 0 deletions feature/onboarding/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="AppTheme.NumberPicker" parent="Theme.Material3.Light">
<item name="colorControlNormal">#FFFFFF</item>
<item name="android:background">#FFFFFF</item>
</style>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.hmh.hamyeonham.feature.onboarding

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ dependencyResolutionManagement {
rootProject.name = "HMH-Android"
include(":app")
include(":core:common")
include(":feature:onboarding")