Skip to content

Commit bf306f5

Browse files
Merge pull request #130 from droidconKE/develop
Merge Develop Changes to Master
2 parents 123d1c0 + dde6d71 commit bf306f5

File tree

358 files changed

+11236
-512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

358 files changed

+11236
-512
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.{kt,kts}]
2+
insert_final_newline=false
3+
max_line_length=off
4+
disabled_rules=no-wildcard-imports,import-ordering

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
pull_request:
7+
branches:
8+
- develop
9+
jobs:
10+
bundle-check:
11+
name: Bundle check
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 10
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: gradle/wrapper-validation-action@v1
17+
- uses: actions/setup-java@v1
18+
with:
19+
java-version: 8
20+
- uses: actions/cache@v1
21+
with:
22+
path: ~/.gradle/caches
23+
key: gradle-${{ runner.os }}-${{ hashFiles('**/build.gradle.kts') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/src/main/kotlin/Dependencies.kt') }}
24+
- name: Unit tests
25+
run: ./gradlew -Pci --console=plain bundleDebug
26+
lint-check:
27+
name: Lint check
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 10
30+
steps:
31+
- uses: actions/checkout@v2
32+
- uses: gradle/wrapper-validation-action@v1
33+
- uses: actions/setup-java@v1
34+
with:
35+
java-version: 8
36+
- uses: actions/cache@v1
37+
with:
38+
path: ~/.gradle/caches
39+
key: gradle-${{ runner.os }}-${{ hashFiles('**/build.gradle.kts') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/src/main/kotlin/Dependencies.kt') }}
40+
- name: Lint checks
41+
run: ./gradlew -Pci --console=plain ktlintFormat ktlintCheck detekt
42+
unit-tests:
43+
name: Unit tests
44+
runs-on: ubuntu-latest
45+
timeout-minutes: 10
46+
steps:
47+
- uses: actions/checkout@v2
48+
- uses: gradle/wrapper-validation-action@v1
49+
- uses: actions/setup-java@v1
50+
with:
51+
java-version: 8
52+
- uses: actions/cache@v1
53+
with:
54+
path: ~/.gradle/caches
55+
key: gradle-${{ runner.os }}-${{ hashFiles('**/build.gradle.kts') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/src/main/kotlin/Dependencies.kt') }}
56+
- name: Unit tests
57+
run: ./gradlew -Pci --console=plain testDebugUnitTest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
/.idea/assetWizardSettings.xml
1010
.DS_Store
1111
/build
12+
/buildSrc/build
1213
/captures
1314
.externalNativeBuild
1415
.cxx
1516
/.idea/
1617
.idea/sonarlint/
1718
app/libs/
19+
buildSrc/build

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 141 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ check **"dependencies"** below
9393

9494
**4. Build Project**
9595

96-
**5. Incase of an error when building project, update your gradle version, Build Tools download**
96+
**5. In case of an error when building project, update your gradle version, Build Tools download**
9797

9898

9999
=======
@@ -141,7 +141,7 @@ Consists of classes and logic that is to be shared across the application. It co
141141

142142
#### Modules To Be There:
143143
With the above in mind, here are the actual modules in the droidconKE2020 app following the guidelines laid above
144-
1. app
144+
1. app
145145
2. core (library)
146146
3. data (library)
147147
4. features - directory for grouping all the feature modules together. It has the following dynamic feature modules:
@@ -156,7 +156,123 @@ With the above in mind, here are the actual modules in the droidconKE2020 app fo
156156
5. repository(library)
157157
6. network(library)
158158

159+
#### Koin Integration & Guides
160+
Dependency injection is integrated into the project based on the
161+
project's architecture. Each modules gradle file has koin dependencies.
162+
163+
**Data module**
164+
165+
The data module define a databaseModule in Module.kt file. The module
166+
defines a room database like:
167+
168+
`single {
169+
Room.databaseBuilder(
170+
androidApplication(),
171+
DroidConDB::class.java,
172+
"droidCon.db")
173+
.build()
174+
}`
175+
176+
Then define entity in its on directory. Each entity defines a Data
177+
Access Object interfaces and data sources. For example, the user
178+
directory includes; user model file, UserDao interface and a
179+
LocalUserDataSource file. To define dependencies follow these steps;
180+
181+
Define a data access object like this;
182+
183+
`@Dao
184+
interface UserDao {
185+
@Query("SELECT * FROM user")
186+
fun getUser(): User
187+
}`
188+
189+
Then define a koin dependency like this:
190+
191+
`factory { get<DroidConDB>().userDao() }`
192+
193+
and a data source dependencies like this:
194+
195+
`factory { LocalUserDataSource(get()) }`
196+
197+
**Network Module**
198+
199+
The network module also defines individual entities which shall contain
200+
response and request bodies (DTOs), if they are necessary, api service
201+
interface and a data source.
202+
203+
To inject dependencies for data sources, do this:
204+
205+
`factory { get<Retrofit>().create(UserAPIService::class.java) }`
206+
207+
for api service interface dependency injection definition add this:
208+
209+
`factory { RemoteUserDataSource(get()) }`
210+
211+
to define data source dependencies.
212+
213+
**Repository Module**
214+
215+
The repository is dependent on the network and data module. To define a
216+
repository dependency, do this:
217+
218+
`factory { UserRepository(get(), get()) }`
219+
220+
The first parameter is the UserLocalDataSource from the data module and
221+
the second is the UserRemoteDataSource from the network module.
222+
223+
**Features**
224+
225+
Each feature depend on the repository module. ViewModel dependencies
226+
require repository dependencies. for viewmodel injection, follow this
227+
steps;
228+
229+
create a class, for example LoginViewModel,
230+
231+
`class AuthViewModel(private val repository: UserRepository): ViewModel() {
232+
fun login(username: String, password: String) {
233+
repository.login(username, password) }
234+
}`
235+
236+
Then in the features di directory, add a viewmodel injection like this:
237+
238+
`viewModel { AuthViewModel(get()) }`
239+
240+
then inject the viewmodel into a fragment/activity
241+
242+
`class AuthFragment: Fragment() {
243+
**val authFragment: AuthFragment by viewModel()**
244+
245+
override fun onCreateView(
246+
inflater: LayoutInflater,
247+
container: ViewGroup?,
248+
savedInstanceState: Bundle?
249+
): View? {
250+
return super.onCreateView(inflater, container, savedInstanceState)
251+
}
252+
}`
253+
254+
#### Gradle
255+
The App uses Kotlin DSL for its gradle due to the obvious advantages Kotlin affords as compared to Groovy.
256+
The Dependencies.kt file under buildSrc is where we store all our App Dependencies and contains the following objects;
257+
1. Versions;
258+
The versions object contains all the Application’s version code and version name as well as all the variable library version codes.
259+
2. BuildPlugins;
260+
This object contains all the plugins required for the build process.
261+
3. Libraries;
262+
This object contains all the required imported application libraries.
263+
4. APIs
264+
This object contains all the required APIs
265+
5. AndroidSDK
266+
This object contains the minSDK, targetSDK and compileSDK version codes
267+
6. TestLibraries
268+
This object contains all the required Libraries for testing.
269+
7. BuildModules
270+
This object is split into Libraries and Features. The Libraries contain the APP module and the other core Modules which are to be reused in different Dynamic features while the Features contain specific functionality of different aspects of the app.
159271

272+
To add a Dependency go to the Dependencies.kt file add it in the required object. Then go to the target build.gradle.kts file and add the code. E.g.;
273+
Implementation(ObjectName.Example)
274+
275+
160276
#### Navigation
161277
The app uses Single Activity Architecture. And follows [Navigation Principles](https://developer.android.com/guide/navigation/navigation-principles) from Jetpack. And since features are all dynamic modules, we have taken advantage of the introduction of the support of dynamic features in the navigation component in the latest [release](https://developer.android.com/jetpack/androidx/releases/navigation#2.3.0-alpha01). How this works is we use fragments in the feature modules and add the fragments to the main nav graph which has the support for adding destinations from dynamic feature modules. More on this is in the [Navigate with dynamic feature modules
162278
](https://developer.android.com/guide/navigation/navigation-dynamic) tutorial. Note: Adding destinations might not work in AS version below 3.6 Release Candidate 3(RC3) and destination fragment name might be in red but no worries, app runs well as expected.
@@ -237,6 +353,28 @@ For any concerns kindly:
237353
- [Fork the project and send a pull request](https://github.com/droidconKE/droidconKE2020App/pulls).
238354

239355

356+
## Coding Convention
357+
358+
- For any view id, ie. Buttons, Edit Texts etc., we will use camelCase ie. btnLogin, etName.
359+
360+
- Classes name end with the name of the component e.g. MainActivity and MainViewModel
361+
362+
- For layout xml files the name of the component comes first i.e. fragment_login
363+
364+
- The parent layout container id is given a prefix layout_ e.g. layout_login
365+
366+
- Value files should always be in plural ie. strings/colors/styles etc.
367+
368+
- String values should be named as txt_login or err_failed and should not be in block and colors values should be in small ie. colorBlue
369+
370+
- Recycler view layouts should start with the prefix item eg. item_sessions
371+
372+
and xml attributes ie. background should be named as btn_login_bg.xml
373+
374+
- Menu items should be named as activity_main it is repetitive to add the term menu since they are contained in the menu directory
375+
376+
- Ideally, in the xml, the first attribute after the tag is id, then width, then height and then anything else android: followed by app and lastly tools:
377+
240378

241379
## License
242380

@@ -278,3 +416,4 @@ Auto-populated from:
278416
2. https://github.com/VMadalin/kotlin-sample-app
279417
3. https://github.com/DroidKaigi/conference-app-2020
280418
4. https://proandroiddev.com/multiple-ways-of-defining-clean-architecture-layers-bbb70afa5d4a
419+

app/build.gradle.kts

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
plugins{
1+
plugins {
22
id(BuildPlugins.androidApplication)
33
id(BuildPlugins.kotlinAndroid)
44
id(BuildPlugins.kotlinAndroidExtensions)
5+
id(BuildPlugins.safeArgs)
6+
id(BuildPlugins.ktlintPlugin)
57
}
68
android {
79
compileSdkVersion(AndroidSDK.compile)
@@ -17,7 +19,10 @@ android {
1719
buildTypes {
1820
getByName("release") {
1921
isMinifyEnabled = false
20-
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
22+
proguardFiles(
23+
getDefaultProguardFile("proguard-android-optimize.txt"),
24+
"proguard-rules.pro"
25+
)
2126
}
2227
}
2328
dynamicFeatures = mutableSetOf(
@@ -26,25 +31,69 @@ android {
2631
BuildModules.Features.About,
2732
BuildModules.Features.Sessions,
2833
BuildModules.Features.Auth,
29-
BuildModules.Features.Speaker,
34+
BuildModules.Features.Speakers,
3035
BuildModules.Features.Feedback
3136
)
37+
38+
viewBinding {
39+
isEnabled = true
40+
}
41+
42+
dataBinding {
43+
isEnabled = true
44+
}
45+
46+
compileOptions {
47+
sourceCompatibility = JavaVersion.VERSION_1_8
48+
targetCompatibility = JavaVersion.VERSION_1_8
49+
}
50+
51+
(kotlinOptions as org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions).apply {
52+
jvmTarget = JavaVersion.VERSION_1_8.toString()
53+
}
54+
}
55+
56+
val intTestDependencies by configurations.creating {
57+
extendsFrom(configurations["androidTestImplementation"])
3258
}
3359

3460
dependencies {
61+
implementation(project(BuildModules.Libraries.Data))
62+
api(project(BuildModules.Libraries.Core))
63+
implementation(project(BuildModules.Libraries.Network))
64+
implementation(project(BuildModules.Libraries.Repository))
65+
3566
api(APIs.ktxCore)
3667
api(APIs.kotlinStandardLibrary)
3768
api(APIs.navigationFragment)
3869
api(APIs.navigationUI)
3970
api(APIs.navigationDynamicFeature)
40-
implementation (fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
71+
api(APIs.fragments)
72+
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
4173
implementation(Libraries.kotlinStandardLibrary)
4274
implementation(Libraries.appCompat)
43-
implementation (Libraries.ktxCore)
44-
implementation (Libraries.constraintLayout)
45-
implementation (Libraries.materialComponents)
46-
testImplementation (TestLibraries.junit4)
47-
androidTestImplementation (TestLibraries.testRunner)
48-
androidTestImplementation (TestLibraries.espresso)
49-
androidTestImplementation (TestLibraries.annotation)
75+
implementation(Libraries.ktxCore)
76+
api(Libraries.constraintLayout)
77+
api(Libraries.materialComponents)
78+
implementation(Libraries.androidAnimation)
79+
api(Libraries.coil)
80+
api(Libraries.shapedImageView)
81+
testImplementation(TestLibraries.junit4)
82+
androidTestImplementation(TestLibraries.testRunner)
83+
androidTestImplementation(TestLibraries.espresso)
84+
androidTestImplementation(TestLibraries.annotation)
85+
86+
// Koin
87+
implementation(Libraries.koinAndroid)
88+
implementation(Libraries.koinExt)
89+
implementation(Libraries.koinScope)
90+
implementation(Libraries.koinViewModel)
91+
92+
androidTestImplementation(TestLibraries.testRules)
93+
androidTestImplementation(TestLibraries.koin)
94+
debugImplementation(TestLibraries.fragment)
95+
androidTestImplementation(TestLibraries.kakao)
96+
implementation(Libraries.googleServices)
97+
// Mock data
98+
api(Libraries.fakeit)
5099
}

app/src/androidTest/java/com/android254/droidconKE2020/ExampleInstrumentedTest.kt

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)