-
Notifications
You must be signed in to change notification settings - Fork 4
π§π»βπ» Conventions
- Fragment λλ Activity μ½λ μ΅μνλ₯Ό μν λ°μ΄ν°λ°μΈλ© μ§ν₯
- 리μ¬μ΄ν΄λ¬ λ·° μμ΄ν
μ λ°μ΄ν° ν΄λμ€λΒ
XxxItem
, xmlμ λ°μΈλ© λ³μλΒitem
Β μ¬μ© - xml viewModel λ°μΈλ© λ³μλ
viewModel
- κΈ°λ³Έ νμ:Β
[what]\_[where]\_[des]
Β ex) tv_addCalendar_titleHeader- μΉμ μ νμ€νκ² κ΅¬λΆν μ μλ€.
- μΈλλ°λ‘ ꡬλΆλμ΄ μνλ μ 보λ₯Ό κ³¨λΌ μ½κΈ° νΈνλ€.
- desλ₯Ό μ½μ λμλ ꡬλΆν΄μ μ½μ μΌμ΄ μλ€.
- κ° μ μμ λ λ¨μ΄ μ΄μμ΄ νΌμ©λ λλ camel caseλ‘ μμ±.
- μΉ΄λ© μΌμ΄μ€λ‘ ꡬλΆλμ§ μλ λ·°(switch, toolbar, ...)λ ν λ€μμ μ¬μ©.
- μ λμ¬λ simple style(textView -> tv)
Prefix | νλ€μ |
---|---|
layout | LinearLayout, ConstraintLayout,include ... |
custom | CustomView |
tv | TextView |
btn | Button |
img | ImageView |
rv | RecyclerView |
cb | CheckBox |
cg | CheckGroup |
switch | Switch |
view | View |
toolbar | Toolbar |
κ·Έ μΈ | CamelCase μκΈμ λ°μ μ§κΈ° |
μ°Έκ³ :Β ν€μ΄λλ¬ drawable κ°μ΄λ
<WHAT>(_<WHERE>)_<DESCRIPTION>(_<SIZE>)
- μ΄λ―Έμ§κ° μ¬λ¬κ΅°λ°μμ νμ©λ κ²½μ°,Β
<WHERE>
λ μλ΅ κ°λ₯νλ€. - μ΄λ―Έμ§μ ν¬κΈ°κ° 1κ°λ°μ μλ κ²½μ°,Β
<SIZE>
λ μλ΅ κ°λ₯νλ€.
What
Prefix | μ€λͺ |
---|---|
btn_ | λ²νΌμΌλ‘ μ°μ΄λ μ΄λ―Έμ§ |
ic_ | μμ΄μ½, 벑ν°μ μ¬μ©νλ μ΄λ―Έμ§ |
bg_ | λ²νΌμ΄ μλ νλ©΄μ 보μ¬μ§λ μ΄λ―Έμ§ |
img_ | μ€μ μ¬μ§μ΄κ±°λ μμ΄μ½ννκ° μλ μΌλ¬μ€νΈννμ μ΄λ―Έμ§ |
div_ | dividerλ‘ νμ©λλ μ΄λ―Έμ§ |
color_ | color selector |
Selector
- λ°°κ²½μ΄λ λ²νΌμμ Viewμ μνμ λ°λΌμ drawableμ΄ λ³ν΄μΌ νλ κ²½μ°μ λν μ΄λ¦μ μλμ κ°λ€.
μν | Suffix |
---|---|
Normal | _normal |
Pressed | _pressed |
Focused | _focused |
Disabled | _disabled |
Selected | _selected |
Activated | _activated |
Background
- λ°°κ²½μμ΄ pressedμνμ λ°λΌμ white -> sky_blueλ‘ λ³νλ κ²½μ°λΒ
bg_white_to_sky_blue.xml
λ‘ νλ€. - λ°°κ²½μ΄ whiteμμ 24dpλ‘ ν
λ리λ₯Ό 그리λ κ²½μ°λΒ
bg_white_radius_24dp.xml
λ‘ νλ€. - λ°°κ²½μ΄ ν¬λͺ
νλ©° λ°°κ²½μ μ λ§μ sky_blueμμ 8dpλ‘ ν
λ리λ₯Ό 그리λ κ²½μ°λΒ
bg_stroke_sky_blue_radius_8dp.xml
λ‘ νλ€. -
μμ
- btn_call_normal.png: μ νκ±ΈκΈ° λ²νΌ μ΄λ―Έμ§
- btn_call_pressed.png: μ νκ±ΈκΈ° λ²νΌ λλ Έμλμ μ΄λ―Έμ§
- btn_call.xml: μ νκ±ΈκΈ° λ²νΌ μ΄λ―Έμ§μ selector xml
- ic_dealer_gift.png: λλ¬κ° 보λ΄μ€ κΈ°νν°μ½μ 보μ¬μ€λ νμλλ μ΄λ―Έμ§
- img_splash_chart.png: μ€νλμ νλ©΄μμ 보μ¬μ§λ μ°¨νΈ μ΄λ―Έμ§
-
item_<what>
: 리μ¬μ΄ν΄λ¬ λ·° μμ΄ν λ μ΄μμμ μ¬μ© -
view_<what>
: 컀μ€ν λ·° λ μ΄μμμ μ¬μ©
Color
<!--color 리μμ€ μ 리-->
<color name="light_gray">#E4E4E4</color>
<color name="gray">#8D8D8D</color>
<color name="gray_alpha_30">#30000000</color>
<!--μ λ³μ wHeRe_wHAt. μ¬λ¬ κ³³μμ μ¬μ©λλ€λ©΄ where μλ΅ κ°λ₯.-->
<color name="saveSchedule_titleText">@color/light_gray</color>
<color name="yearCalendarView_titleText">@color/gray</color>
<color name="close_background">@color/gray_alpha_30</color>
descriptionμ ν λ§ μμ±μΌλ‘ λΆλ¦¬
<item name="titleTextColor">@color/yellow_500</item>
λ μ΄μμμμ μ¬μ©μ ν λ§ μμ±μ μ°Έμ‘°
style="@style/Theme.titleTextColor"
Mnemonic μ¬μ©
κ°μ₯ μΌλ°μ μΈ margin/padding 16dp
= βμΌλ° μΉμ ν¬κΈ°μ 100% μ¬μ©β
<dimen name="small_25">2dp</dimen>
<dimen name="small_50">4dp</dimen>
<dimen name="small_100">8dp</dimen> <!-- 50% of normal = 8dp -->
<dimen name="normal_100">16dp</dimen> <!-- 100% of normal = 16dp -->
<dimen name="normal_125">20dp</dimen> <!-- 125% of normal = 16dp + 4dp = 20dp -->
<dimen name="normal_150">24dp</dimen>
<dimen name="normal_175">28dp</dimen>
<dimen name="large_100">32dp</dimen> <!-- large_100 = 2 x normal_100 -->
<dimen name="large_125">40dp</dimen>
<dimen name="large_150">48dp</dimen>
<dimen name="large_175">56dp</dimen>
<dimen name="large_200">64dp</dimen>
μΌλ° μΉμμ λΉν΄ ν¨μ¬ ν° dimensionsμ κ²½μ°
- κΈ°λ³Έ νμ :
[what]_[where]_[des]_[size]
ex) keyline_all_text
<dimen name="size_selectVideo_player">500dp</dimen>
<WHAT>
Prefix | Usage |
---|---|
width | width in dp |
height | height in dp |
size | if width == height |
margin | margin in dp |
padding | padding in dp |
elevation | elevation in dp |
keyline | absolute keyline measured from view edge in dp |
textsize | size of text in sp |
Android - Dimensions by Conventions
- μΉ΄λ©μΌμ΄μ€
- κΈ°λ³Έ νμ:Β
[des][View]
Β ex) customText
<style name="selectVideoOptionImage" parent="Widget.AppCompat.ImageButton">
<item name="android:layout_width">@dimen/large_125</item>
<item name="android:layout_height">@dimen/large_125</item>
<item name="elevation">@dimen/small_25</item>
<item name="android:padding">@dimen/small_100</item>
</style>
Style resource | Android Developers
λ¨μ΄μ 첫 κΈμλ§ upper case
class Person
class User
1 λ 1 κ΄κ³λ©΄ viewModel
1λ1 λ€ κ΄κ³λ©΄ νλ€μ
val viewModel: AddTaskViewModel by viewModels()
val activityViewModel: MainViewModel by viewModels()
val addTakAdapter = AddTaskAdapter()
μ½νλ¦° 곡μ λ©μλ λ€μ΄λ°
첫 λ¨μ΄λ₯Ό μ μΈν λ¨μ΄λΆν° λ¨μ΄μ 첫 κΈμλ§ upper case
λμ¬ νΉμ λμ¬κ΅¬(λμ¬λ‘ μμ)
fun getPersonId() {}
fun getUserId() {}
- νλ‘νΌν°
- μμ±μ
- init
- onCreate
- onCreateView
- ν¨μ
- onDestroy
- companion object
interface Example{
// λκΈ°
fun A()
fun B()
fun C()
// λκΈ°
}
class D(
a,
b,
c // 140 space λ§μΆ°μ (Arrange Option λ³κ²½νκΈ°)
) : B {
// λκΈ°
private val _binding
private val binding = get() = _binding
private val viewModel by viewModels{}
private lateinit var
private val a = 3
init {
}
override onCreate()
private fun()
override onDestroy()
inner class C() {
}
companion object {
}
}
//single Event
class Adapter(val onClick : (String) -> Unit)
//Multiple Event
class Adapter(val onClick : MinSeokOnClickListener)
fun interface MinSeokOnCLickListener {
fun onClick(str : String)
fun onLongClick(str : String)
}
val onclickListener = object: MinSeokOnCLickListener {
fun onClick(str : String) {
}
fun onLongClick(str : String) {
}
}
Adapter(onclickListener)
Adapter(::onClick) // 3μ€ μ΄μ λΆλ¦¬
Adapter {
Log.d("asd", it)
} // 2μ€ μ΄λ΄ μ¬μ©
[What]Type
NetworkState(= retrofit Result) MultipleViewType
apply, also, with, let, run
- Scope μ€μ²© μ§μ(μ΅λ 2μ€μ²©)
- it μ§μ (λ€λ₯Έ μ΄λ¦μΌλ‘ μ μΈν΄μ μ°κΈ°)
λΉλκΈ° ν¨μ
- fetch: Read
- post : Write view(viewModel.fetchData) -> viewModel(repo.fetchData) -> repo(source.fetchData)
μΆκ°
- add: list μμ λ£μ λ
- create: μλ‘ μμ±
μ‘°ν
- get: any
- find: nullable any
- is, has: boolean
νλ©΄μ ν
- show[Dialog]
- start[Activity]
- navigate[Fragment]
νλ©΄ κ°±μ
- show
- invalidate
else if μ¬μ© κΈμ§ -> whenμΌλ‘ λ³ν elseλ μ§μ κ³ λ € μ€κ΄νΈ 무쑰건 μ°κΈ°
// μ€κ΄νΈ νμ€ν μ¬μ©νκΈ°
if (true) {
foo()
} else {
bar()
}
// else μ§μ
β¬οΈ
bar()
if (true) {
foo()
}
// μλ μ λ ¬ μ¬μ©νκΈ°
when {
aaa -> {
}
bbb -> {
}
}
// 2μ€ μ΄μμ μ€κ΄νΈ λ΄μμ, 1μ€μ μ€κ΄νΈ x
when {
aaa -> foo()
bbb -> bar()
}
// early return
// else λ¬Έμ 미리 when μμ λΉΌμ return μν€κΈ° (else blockμμ μ²λ¦¬ν κ²μ΄ μμ λ)
val xxx = ... ?: return
when(target) {
aaa -> {}
bbb -> {}
}
ShoppingFragment -> ShoppingDetailFragment
// 1. ShoppingFragment with Safe Args
override fun navigateToShoppingDetail(shoppingItemInfo: ShoppingItemInfo) {
val navAction = ShoppingFragmentDirections.actionShoppingFragmentToDetailFragment(shoppingItemInfo)
findNavController().navigate(navAction)
}
// 2 ShoppingDetailFragment
class ShoppingDetailFragment : Fragment(), ShoppingItemOnClickListener {
private val args: ShoppingDetailFragmentArgs by navArgs()
private val shoppingItemInfo : ShoppingItemInfo by lazy { args.shoppingItemInfo }
override fun onCreateView(...){...}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Log.d("shoppingItemInfo",shoppingItemInfo.toString()) // μ¬μ©
}
resource -> νλ©΄μ 보μ΄λκ°λ₯Ό κΈ°μ€μΌλ‘ string.xmlμ λΆλ¦¬ κ²°μ
- ex: EXTRA_TITLE_ID = "title_id" μμ λ€μ΄λ°μ upper snake case
μλ―Έ μλ μ«μ, λ¬Έμμ΄μ companionμ const val μ μΈ
- ex: LOOP_COUNT = 10
- fromΒ β
- νκ΅μ΄, snake case
instrument ok
fun `μΌμ μ_μλͺ»_κ°μ Έμ¬_λ`()
Issue #<number> type: subject
body(option)
footer(option)
- feat:Β μλ‘μ΄ κΈ°λ₯
- fix:Β λ²κ·Έ μμ
- docs:Β README, gitignore μ£Όμ μμ
- refactor:Β μ½λ 리ν©ν°λ§
- test:Β ν μ€νΈ μ½λκ° μΆκ°λκ±°λ 리ν©ν°λ§ μ μ¬μ©νλ©° νλ‘λμ μ½λλ λ³κ²½λμ§ μλλ€.
- chore:Β νλ‘μ νΈ νκ²½μ€μ λ³κ²½, λΉλ κ΅¬μ± λ³κ²½ λ±μ μ¬μ©λλ©° νλ‘λμ μ½λλ λ³κ²½λμ§ μλλ€.
- res
β μλ¬Έμ:
- 50μ μ΄λ΄
- ꡬμ΄μ²΄/λ¬Έμ₯ν X, λͺ λ ΉνμΌλ‘ μμ±
- λ§μΉ¨ν μ¬μ© λΆκ°
- μλ΅ κ°λ₯
- 72μ μ΄λ΄
- μ΄λ€(What) μμ μΈμ§, μμ μ λͺ©μ (Why)μ λν΄ μμ±. μμ μ ν΄κ²°ν λ°©μ(How)μ μμ± X
- Issue Tracker ID νμ
- Issue Tracker μ
- Fixes: μ΄μ μμ μ€ (μμ§ ν΄κ²°λμ§ μμ κ²½μ°)
- Resolves: μ΄μλ₯Ό ν΄κ²°νμ λ μ¬μ©
- Ref: μ°Έκ³ ν μ΄μκ° μμ λ μ¬μ©
- Related to: ν΄λΉ 컀λ°μ κ΄λ ¨λ μ΄μλ²νΈ (μμ§ ν΄κ²°λμ§ μμ κ²½μ°)
λΌλ²¨ λ¬κΈ°(chore, bug, fix, feature, docs, help wanted, wrong, question)
- projectλ¬κΈ°
- Milestone λ¬κΈ°
- asignees μ§μ
# PR λ΄μ©
...μμ
λ΄μ©...
# μ§ν μν©
...체ν¬ν¬μΈνΈ...