|
40 | 40 | ## 📁 Project Structure |
41 | 41 |
|
42 | 42 | ``` |
43 | | -CodeTemplates/ |
44 | | -├── java/ |
45 | | -│ ├── data/ |
46 | | -│ │ ├── dao/ # Data Access Objects |
47 | | -│ │ ├── database/ # Room Database |
48 | | -│ │ └── repository/ # Data Repositories |
49 | | -│ ├── model/ # Data Models |
50 | | -│ ├── ui/ |
51 | | -│ │ ├── adapter/ # RecyclerView Adapters |
52 | | -│ │ ├── components/ # Custom UI Components |
53 | | -│ │ ├── holder/ # ViewHolders |
54 | | -│ │ ├── navigation/ # Navigation Components |
55 | | -│ │ └── viewmodel/ # ViewModels |
56 | | -│ └── util/ # Utility Classes |
57 | | -└── res/ |
58 | | -├── layout/ # Layout Templates |
59 | | -├── menu/ # Menu Resources |
60 | | -└── values/ # Style Resources |
| 43 | +C:. |
| 44 | +│ LICENSE # License file for the project |
| 45 | +│ README.md # Project documentation |
| 46 | +│ |
| 47 | +└───CodeTemplates # Main source directory |
| 48 | + ├───java # Java source files |
| 49 | + │ │ CustomNavigatorMainActivity.java # Main activity of the application |
| 50 | + │ │ |
| 51 | + │ ├───data # Data layer (DAO, Database, Repository) |
| 52 | + │ │ ├───dao |
| 53 | + │ │ │ CustomDAO.java # Data Access Object for database operations |
| 54 | + │ │ │ |
| 55 | + │ │ ├───database |
| 56 | + │ │ │ CustomDatabase.java # Database setup and instance management |
| 57 | + │ │ │ |
| 58 | + │ │ └───repository |
| 59 | + │ │ CustomRepository.java # Handles data operations and business logic |
| 60 | + │ │ |
| 61 | + │ ├───model # Data models used in the application |
| 62 | + │ │ CustomModel.java # Example model class |
| 63 | + │ │ |
| 64 | + │ ├───ui # UI components of the application |
| 65 | + │ │ ├───adapter |
| 66 | + │ │ │ CustomAdapter.java # Adapter for RecyclerView or ListView |
| 67 | + │ │ │ |
| 68 | + │ │ ├───components |
| 69 | + │ │ │ CustomInfoButton.java # Custom UI component (e.g., button) |
| 70 | + │ │ │ |
| 71 | + │ │ ├───fragment |
| 72 | + │ │ │ CustomListFragment.java # Fragment to display a list of items |
| 73 | + │ │ │ |
| 74 | + │ │ ├───navigation |
| 75 | + │ │ │ BottomNavigation.java # Bottom navigation bar implementation |
| 76 | + │ │ │ SideMenu.java # Side navigation drawer implementation |
| 77 | + │ │ │ |
| 78 | + │ │ ├───viewHolder |
| 79 | + │ │ │ CustomViewHolder.java # ViewHolder for RecyclerView items |
| 80 | + │ │ │ |
| 81 | + │ │ └───viewModel |
| 82 | + │ │ CustomViewModel.java # ViewModel for managing UI-related data |
| 83 | + │ │ |
| 84 | + │ └───util # Utility classes |
| 85 | + │ CustomUtility.java # General utility functions |
| 86 | + │ NavigationUtil.java # Navigation-related utility functions |
| 87 | + │ |
| 88 | + └───res # Resource files (XML layouts, styles, colors) |
| 89 | + ├───layout |
| 90 | + │ custom_bottom_nav_layout.xml # XML layout for bottom navigation |
| 91 | + │ custom_button_layout.xml # XML layout for custom button |
| 92 | + │ custom_card_layout.xml # XML layout for custom card UI |
| 93 | + │ custom_login_layout.xml # XML layout for login screen |
| 94 | + │ custom_navigator_main_activity.xml # XML layout for main activity |
| 95 | + │ custom_side_nav_layout.xml # XML layout for side navigation menu |
| 96 | + │ custom_toolbar_layout.xml # XML layout for toolbar |
| 97 | + │ |
| 98 | + ├───menu |
| 99 | + │ custom_bottom_nav_menu.xml # Menu configuration for bottom navigation |
| 100 | + │ custom_main_nav_menu.xml # Main navigation menu configuration |
| 101 | + │ custom_side_nav_menu.xml # Side navigation menu configuration |
| 102 | + │ |
| 103 | + └───values |
| 104 | + custom_colors.xml # Color definitions |
| 105 | + custom_dimes.xml # Dimens (sizes and spacing) |
| 106 | + custom_styles.xml # Style definitions |
61 | 107 | ``` |
62 | 108 |
|
| 109 | + |
63 | 110 | ## 📁 Java Templates Overview |
64 | 111 |
|
65 | | -| Template | Description | Location | |
66 | | -|----------|-------------|----------| |
67 | | -| [CustomAdapter.java](CodeTemplates/java/ui/adapter/CustomAdapter.java) | RecyclerView adapter template with ViewHolder pattern implementation. Features: click listener interface, data binding functionality, list management methods | `ui/adapter` | |
68 | | -| [CustomBottomNavigation.java](CodeTemplates/java/ui/navigation/CustomBottomNavigation.java) | Material Design bottom navigation implementation with pre-configured listener and customizable menu items | `ui/navigation` | |
69 | | -| [CustomDAO.java](CodeTemplates/java/data/dao/CustomDAO.java) | Room Database DAO interface template with CRUD operations, LiveData support, and ordered queries | `data/dao` | |
70 | | -| [CustomDatabase.java](CodeTemplates/java/data/database/CustomDatabase.java) | Room Database singleton template with instance management and migration handling | `data/database` | |
71 | | -| [CustomInfoButton.java](CodeTemplates/java/ui/components/CustomInfoButton.java) | Custom ImageButton implementation with Material Design integration and click handling | `ui/components` | |
72 | | -| [CustomModel.java](CodeTemplates/java/model/CustomModel.java) | Room Entity model template with basic data structure and primary key configuration | `model` | |
73 | | -| [CustomNavigationUtil.java](CodeTemplates/java/util/CustomNavigationUtil.java) | Navigation utility class for activity navigation and intent management | `util` | |
74 | | -| [CustomRepository.java](CodeTemplates/java/data/repository/CustomRepository.java) | Repository pattern implementation with ExecutorService and LiveData management | `data/repository` | |
75 | | -| [CustomSideMenu.java](CodeTemplates/java/ui/navigation/CustomSideMenu.java) | Navigation drawer implementation with Material Design NavigationView | `ui/navigation` | |
76 | | -| [CustomUtility.java](CodeTemplates/java/util/CustomUtility.java) | General utility class template with static helper methods | `util` | |
77 | | -| [CustomViewHolder.java](CodeTemplates/java/ui/holder/CustomViewHolder.java) | RecyclerView ViewHolder template with view and data binding methods | `ui/holder` | |
78 | | -| [CustomViewModel.java](CodeTemplates/java/ui/viewmodel/CustomViewModel.java) | AndroidViewModel implementation with repository integration and CRUD operations | `ui/viewmodel` | |
| 112 | +| Template | Description | Location | |
| 113 | +|-----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------| |
| 114 | +| **CustomNavigatorMainActivity.java** | Custom main activity template for navigation-based Android applications. Features: Navigation Component setup, Drawer and Bottom Navigation integration, Toolbar, and overflow menu. | `java` | |
| 115 | +| **CustomDAO.java** | Room Database DAO interface template with CRUD operations, LiveData support, and ordered queries. | `java/data/dao` | |
| 116 | +| **CustomDatabase.java** | Room Database singleton template with instance management and migration handling. | `java/data/database` | |
| 117 | +| **CustomRepository.java** | Repository pattern implementation with ExecutorService and LiveData management. | `java/data/repository` | |
| 118 | +| **CustomModel.java** | Room Entity model template with a basic data structure and primary key configuration. | `java/model` | |
| 119 | +| **CustomAdapter.java** | RecyclerView adapter template implementing the ViewHolder pattern. Features click listener interface, data binding functionality, and list management methods. | `java/ui/adapter` | |
| 120 | +| **CustomInfoButton.java** | Custom ImageButton implementation with Material Design integration and click handling. | `java/ui/components` | |
| 121 | +| **CustomListFragment.java** | Fragment template that displays a list of items using RecyclerView, ViewModel, and NavigationUtil. Supports different LayoutManagers and handles item click navigation. | `java/ui/fragment` | |
| 122 | +| **BottomNavigation.java** | Material Design bottom navigation implementation with pre-configured navigation listener. Supports both fragment-based and intent-based navigation. | `java/ui/navigation` | |
| 123 | +| **SideMenu.java** | Navigation drawer implementation using Material Design NavigationView. Provides menu item handling using NavigationUtil for seamless navigation. | `java/ui/navigation` | |
| 124 | +| **CustomViewHolder.java** | RecyclerView ViewHolder template with view binding and data binding methods for efficient view recycling. | `java/ui/viewHolder` | |
| 125 | +| **CustomViewModel.java** | AndroidViewModel implementation with repository integration and CRUD operations, facilitating separation of concerns and lifecycle-aware data handling. | `java/ui/viewModel` | |
| 126 | +| **CustomUtility.java** | General utility class template with static helper methods. | `java/util` | |
| 127 | +| **NavigationUtil.java** | Utility class for handling navigation throughout the app. Supports fragment-based navigation via NavController and intent-based navigation methods. | `java/util` | |
79 | 128 |
|
80 | 129 | ## 📁 XML Templates Overview |
81 | 130 |
|
82 | 131 | ### Layouts |
83 | 132 |
|
84 | | -| Template | Description | |
85 | | -|----------|-------------| |
86 | | -| [custom_login_layout.xml](CodeTemplates/res/layout/custom_login_layout.xml) | Material Design login screen with email and password fields | |
87 | | -| [custom_bottom_nav_layout.xml](CodeTemplates/res/layout/custom_bottom_nav_layout.xml) | Bottom navigation with fragment container | |
88 | | -| [custom_side_nav_layout.xml](CodeTemplates/res/layout/custom_side_nav_layout.xml) | Navigation drawer with header and menu | |
89 | | -| [custom_card_layout.xml](CodeTemplates/res/layout/custom_card_layout.xml) | Material card with image, title, and subtitle | |
90 | | -| [custom_button_layout.xml](CodeTemplates/res/layout/custom_button_layout.xml) | Collection of Material button styles | |
91 | | -| [custom_toolbar_layout.xml](CodeTemplates/res/layout/custom_toolbar_layout.xml) | Custom toolbar with title and menu support | |
| 133 | +| Template | Description | |
| 134 | +|------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| |
| 135 | +| **custom_login_layout.xml** | Material Design login screen with email and password fields. | |
| 136 | +| **custom_bottom_nav_layout.xml** | Layout for bottom navigation integrated with a fragment container. | |
| 137 | +| **custom_side_nav_layout.xml** | Layout for a navigation drawer with header and menu items. | |
| 138 | +| **custom_card_layout.xml** | Material card layout with image, title, and subtitle. | |
| 139 | +| **custom_button_layout.xml** | Layout showcasing various Material button styles. | |
| 140 | +| **custom_toolbar_layout.xml** | Custom toolbar layout with title and menu support. | |
| 141 | +| **custom_navigator_main_activity.xml** | Layout for CustomNavigatorMainActivity, including AppBarLayout with Toolbar, FragmentContainerView, BottomNavigationView, and NavigationView for side menu. | |
92 | 142 |
|
93 | 143 | ### Menus |
94 | 144 |
|
95 | | -| Template | Description | |
96 | | -|----------|-------------| |
97 | | -| [custom_bottom_nav_menu.xml](CodeTemplates/res/menu/custom_bottom_nav_menu.xml) | Bottom navigation menu items | |
98 | | -| [custom_side_nav_menu.xml](CodeTemplates/res/menu/custom_side_nav_menu.xml) | Navigation drawer menu items | |
| 145 | +| Template | Description | |
| 146 | +|------------------------------------|----------------------------------------------------------------------------------------------------------------| |
| 147 | +| **custom_bottom_nav_menu.xml** | Menu resource for bottom navigation items. | |
| 148 | +| **custom_main_nav_menu.xml** | Menu resource for the overflow menu in CustomNavigatorMainActivity. | |
| 149 | +| **custom_side_nav_menu.xml** | Menu resource for navigation drawer items. | |
99 | 150 |
|
100 | 151 | ### Values |
101 | 152 |
|
102 | | -| Template | Description | |
103 | | -|----------|-------------| |
104 | | -| [custom_colors.xml](CodeTemplates/res/values/custom_colors.xml) | Material Design color system | |
105 | | -| [custom_dimens.xml](CodeTemplates/res/values/custom_dimes.xml) | Standard dimensions and spacing | |
106 | | -| [custom_styles.xml](CodeTemplates/res/values/custom_styles.xml) | Material component styles | |
| 153 | +| Template | Description | |
| 154 | +|----------------------------|----------------------------------------------| |
| 155 | +| **custom_colors.xml** | Material Design color system. | |
| 156 | +| **custom_dimes.xml** | Standard dimensions and spacing. | |
| 157 | +| **custom_styles.xml** | Material component styles and themes. | |
107 | 158 |
|
108 | 159 | ## 🚀 How to Use |
109 | 160 |
|
110 | 161 | ### Setting Up Templates in Android Studio |
111 | 162 |
|
112 | | -1. Open Android Studio |
113 | | -2. Go to `File > Settings` (Windows/Linux) or `Android Studio > Preferences` (macOS) |
114 | | -3. Navigate to `Editor > File and Code Templates` |
115 | | -4. Click the `+` icon to create a new template |
116 | | -5. For each template below, create a new entry with the specified Name and File Name |
117 | | -6. Click `Enable Live Template` and then click `Apply` |
| 163 | +1. Open **Android Studio**. |
| 164 | +2. Navigate to **File > Settings** (Windows/Linux) or **Android Studio > Preferences** (macOS). |
| 165 | +3. Go to **Editor > File and Code Templates**. |
| 166 | +4. Click the **+** icon to create a new template. |
| 167 | +5. For each template listed above, create a new entry with the specified **Name** and **File Name**. |
118 | 168 |
|
119 | 169 | ### Using the Templates |
120 | 170 |
|
121 | | -1. Right-click on your desired package in the Project view |
122 | | -2. Select `New > [Template Name]` |
123 | | -4. Click `OK` |
| 171 | +1. In the Project view, right-click on your desired package. |
| 172 | +2. Select **New > Other > [Template Name]**. |
| 173 | +3. Enter the name for your class (this replaces the `${NAME}` variable in the template). |
| 174 | +4. Click **OK**. |
124 | 175 |
|
125 | 176 | ### Template Variables |
126 | 177 |
|
127 | | -When using the templates, you'll need to replace these common variables: |
128 | | -- `${PACKAGE_NAME}`: Your app's package name |
129 | | -- Other template-specific variables will be highlighted when you use the template |
130 | | - |
131 | | -### Tips |
| 178 | +Replace the following common variables when using these templates: |
| 179 | +- `${PACKAGE_NAME}`: Your app's package name. |
| 180 | +- `${NAME}`: The name you input when creating a new file. |
| 181 | +- Other template-specific variables will be highlighted during template usage. |
132 | 182 |
|
133 | | -- Templates can be modified after creation in the File and Code Templates settings |
134 | | -- You can add your own variables using the `#set($VARIABLE_NAME = "value")` syntax |
135 | | -- Use `$NAME` to reference the input name in your template |
136 | | -- Use `${PACKAGE_NAME}` to reference the current package |
| 183 | +*Tips:* |
| 184 | +- Templates can be modified post-creation in the File and Code Templates settings. |
| 185 | +- Custom variables can be added using the `#set($VARIABLE_NAME = "value")` syntax. |
| 186 | +- Use `$NAME` to reference the input name in your template. |
| 187 | +- Use `${PACKAGE_NAME}` to reference the current package. |
137 | 188 |
|
138 | 189 | ## 📚 Dependencies |
139 | 190 |
|
140 | | -Add these dependencies to your app's `build.gradle` file as needed: |
| 191 | +Add the following dependencies to your app's `build.gradle` file as needed: |
141 | 192 |
|
142 | 193 | ```gradle |
143 | 194 | dependencies { |
144 | | - // AndroidX |
| 195 | + // AndroidX Libraries |
145 | 196 | implementation 'androidx.appcompat:appcompat:x.x.x' |
146 | 197 | implementation 'com.google.android.material:material:x.x.x' |
147 | 198 | |
148 | | - // Room |
| 199 | + // Room Database |
149 | 200 | implementation 'androidx.room:room-runtime:x.x.x' |
150 | 201 | annotationProcessor 'androidx.room:room-compiler:x.x.x' |
151 | 202 |
|
152 | 203 | // LiveData & ViewModel |
153 | 204 | implementation 'androidx.lifecycle:lifecycle-viewmodel:x.x.x' |
154 | 205 | implementation 'androidx.lifecycle:lifecycle-livedata:x.x.x' |
| 206 | + |
| 207 | + // Navigation Component |
| 208 | + implementation 'androidx.navigation:navigation-fragment:x.x.x' |
| 209 | + implementation 'androidx.navigation:navigation-ui:x.x.x' |
155 | 210 | } |
156 | 211 | ``` |
157 | 212 |
|
|
0 commit comments