📜 ⬆️ ⬇️

Android Application Development Standard

Android developer is faced with a large number of files and resources intended for different parts of the program. Even he himself in a month can not remember which file or resource belongs to what.
The material proposed below is based on my experience in developing many projects for Android and has already been tested in several projects. As a result of simple rules, jumble of files and resources becomes a readable project, saves time and nerves. Especially it turned out to be convenient when working in a team, when new programmers can join the project. In Eclipse, you can easily find any resources because they are unique, easily found and sorted in a clear order in any lists. General convenient rules make it easy to read someone else's code and find the right resources.

Most of this is my personal opinion.


')

Android Application Development Standard



All file names


The file name is written in small letters, reflects the readable name of the element, perhaps in a few words. Space is replaced by underscore.

Location of user files on the SD card


Root directory for all files except user temporary:
/ sdcard / project name / , for example / sdcard / TalentMania /

Music catalog:
/ sdcard / project name / sound / , for example / sdcard / TalentMania / sound /
MIDI Catalog:
/ sdcard / project name / midi / , for example / sdcard / TalentMania / midi /
Catalog for graphics:
/ sdcard / project name / img / , for example / sdcard / TalentMania / img /

Subdirectories for different activit files:
/ sdcard / project name / img / activation name / , for example / sdcard / TalentMania / img / guitar /

Location of temporary files - use standard File class functions:
createTempFile (String prefix, String suffix, File directory)
If you’re on an empty file, you’ll find out what to do.
createTempFile (String prefix, String suffix)
Prefix and file name.

File locations in application resources


Graphics and sounds intended for use in assets (for example, the AndEngine library) are grouped into the following directories:
MIDI files - assets / midi /
Sprite graphics - assets / gfx /
TTF fonts - assets / font /
Shared files used by different activities are located in the root. Files used by only one activity are located in the appropriate subdirectory, for example: assets / gfx / guitar /

MP3 files are located in the res / raw / directory.

Icon Names


The names of the icons used prefix describing its type

Ic_ icons Example: ic_star.png
Launch icons ic_launcher_ Example: ic_launcher_calendar.png
Menu icons ic_menu_ Example: ic_menu_archive.png
Icons bar status ic_stat_sys_ or ic_stat_notify_ Example: ic_stat_notify_msg.png
Icons tabs ic_tab_ Example: ic_tab_recent.png
Dialog icons ic_dialog_ Example: ic_dialog_info.png

Buttons


bt_name_pressed.png (image clicked) and bt_name_default.png (default image)
The xml describing the animation is placed in the drawable directory ! - bt_name.xml

Layouts


The main layouts correspond to the names of the activators.
ac_class_name.xml - corresponds to the name of the activation class AcNameClass.java.

Additional views for this layout correspond to the names of the activators + name view ac_name_class_name_view_name_name.xml

view_name_view.xml - general view for different layouts.
adt_adapter_name.xml - layout name for list adapter
dialog_dialog_name.xml - the name of the dialog

Names of elements in the layout


The name of the element used in the layout is
Ac Name of Layer Name of Element

for example: android: id = "@ + id / AcMenuTemplateTopPanel" indicates that the element is called “top panel” and is intended to activate AcMenuTemplate

Animation


animation description files are saved in the res / drawable directory .
For buttons - bt_name_anim.png
For animation - anim_a_a_activity_i___animacii.png
If there is a lot of animation, it is more convenient to place it in a separate res / anim directory

Graphics


The background is bg_orientation_name.png .
Image - im_name.png

Package name


Activity - activities
Adapters
Data - data
Conversations - dialogs
Interfaces - interfaces
Views - views

Class name


Activi - AcName Activi
Adapters for listings - Adt Name Adapter
Dialogues - DialogName Dialog
Interface- InterfaceName Interface

Total


The proposed standard is not a dogma and is constantly subject to change as empirical experience accumulates. I hope to hear feedback and suggestions on this topic. It is interesting to learn from the experience of other developers.

Source: https://habr.com/ru/post/111868/


All Articles