Guideline for android developer in Distinction On Technology (PT. DOT Indonesia)
Click to show
Please refer to this document to meet our style guidelines:
Always push your code into develop branch, and do a merge request into master branch after stabilize and refactor your code
Create your own branch for each feature of the apps
Always use the libraries from these repository:
Separate resource for each features
res-feature
│
├─── auth (features name)
│ │
│ ├─── layout
│ │ └─ Layout inside package
│ │
│ └─── values
│ └─ String inside package
│
├─── main (main package)
│
├─── menu (menu package)
│
│─── widget (widget package)
│
├─── layout (layout that used multiple times i.e. partial layout)
│
└─── values (values contains more than one time, tools i.e (lorem, image url), never used)
├─── attrs
├─── colors
├─── dimens
├─── other values
├─── strings
└─── styles
Standard name declaration to collaborate with other
-
Type Usage Example Class PascalCase MainActivityLocal Variable camelCase imageViewConstants UPPER_SNAKE_CASE BASE_URLResource lower_snake_case activity_mainResource IDs camelCase ivMain -
Type Prefix Example View (viewType ViewID) ivSplashObject (Object Name) networkViewModel --- viewModelBinding binding( Binding Nameif more than one)bindingMainorbindingConstants WHERE_WHAT NETWORK_REQUEST_CODE -
Resource Naming Based
'WHAT'_ 'WHERE'_ 'DESCRIPTION'WHAT WHERE DESCRIPTION FIXED (btn, rv) LOCATION difference multiple 'WHAT' in 'WHERE' Component Class Name Layout Name Activity MainBroadcastMessageActivityactivity_main_broadcast_message.xmlFragment FragmentHomefragment_home.xmlDialog --- dialog_rating.xmlAdapter ForumImageAdapter--- AdapterView item --- item_forum_image.xmlPartial layout --- view_aduan_location.xmlComponent Prefix Example Button btnbtnRegisterSignupTextView tvtvWelcomeTitleEditText etetLoginPasswordImageView ivivSplashLogoRelativeLayout rlrlMainRootLinearLayout llllLoginRootConstraintLayout clclSplashRootTableLayout tltlDetailSheetTabLayout tabtabMainNavListView lvlvDetailMessagesRecyclerView rvrvChatCheckbox cbcbLoginRememberMeProgressBar pbpbRegisterUploadPercentRadioGroup rgrgInputGenderRadioButton rbrbInputFemaleToggleButton tbtbControlVisibilitySpinner spinspinEditProfileLocationMenu menumenuMainSearchGalleryView gvgvMainAlbumWebView wvwvMainPreviewBottom Navigation botnavbotNavMainLibrary Layout liblibMainBotNavCustom Widget wgwgMainGridRvLayout Binding ViewModel --- vmAsset Type Prefix (WHAT) Example Action bar ab_main_ab_login.9.pngButton btn_login_btn_send_pressed.9.pngBackground bg_login_bg_dialog_top.9.pngDialog dialog_all_dialog_top.9.pngDivider divider_all_divider_horizontal.9.pngIcon ic_splash_ic_star.pngNotification notification_login_notification_bg.9.pngTabs tab_main_tab_pressed.9.pngAsset Type Prefix Example Icons ic_ic_star.pngLauncher icons ic_launcheric_launcher_calendar.pngMenu icons and Action Bar icons ic_menuic_menu_search.pngStatus bar icons ic_stat_notifyic_stat_notify_msg.pngTab icons ic_tabic_tab_recent.pngDialog icons ic_dialogic_dialog_info.pngTYPE Location Prefix Example More than one features/package root all_all_et_hint_nameMenu title feature location menu_fragment_list_menu_search.pngaction feature location act_login_act_clickederror warning success message feature location msg_network_msg_upload_successlabel root --- all_nameview inside layout feature location view prefix_(tv_, btn_, et_)splash_tv_titlelogin_btn_label,register_et_email_hintapp_name gradle/productFlavors --- resValue "string", "app_name", "Dev"API ENDPOINT gradle/productFlavors --- buildConfigField "String", "END_POINT", "\"https://sandbox.dot.co.id/project-name/api/v1/\""Gradle string Location is used for changed productFlavor i.e
developmentstagingproduction
- Set Hierarchy view from android to Project
- create directory
res-featuresinapp/src/main - create directory for each features in
res-features - Go to build.gradle
app level - add this in the android section
android { ... sourceSets { main { res.srcDirs = [ 'src/main/res', 'src/main/res-features', 'src/main/res-features/main', 'src/main/your-path', ] } } } - Sync project with gradle
- https://github.com/ribot/android-guidelines/blob/master/project_and_code_guidelines.md
- https://google.github.io/styleguide/javaguide.html#s5.1-identifier-names
- https://jeroenmols.com/blog/2016/03/07/resourcenaming/
