Skip to content

Commit 4b3d5bf

Browse files
Merge pull request #11 from ImaginativeShohag/dev
Dependencies updated, readme updated, latex, event class, ignoreCrash, userCase etc added
2 parents f070e65 + 5875ffc commit 4b3d5bf

36 files changed

Lines changed: 791 additions & 340 deletions

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
A simple Android MVVM pattern example and template.
44

5-
## Android Studio Version
6-
7-
- Android Studio Arctic Fox | 2020.3.1 Patch 2
8-
95
## Used Components/Libraries
106

117
- Kotlin
@@ -26,9 +22,13 @@ A simple Android MVVM pattern example and template.
2622

2723
## Others
2824

29-
- Build variant (https://developer.android.com/studio/build/build-variants)
25+
- Custom Build variant (https://developer.android.com/studio/build/build-variants)
26+
- Environment variable based on Build variant
3027
- Custom Snackbar
3128
- Dark Mode
29+
- Awesome module naming example (see `AwesomeModuleConstants`)
30+
- Dynamic accent color from image (see `calculatePaletteInImage()`)
31+
- Simple Encryption Utils (see `EncryptionUtils`)
3232

3333
## Extension Functions (see `utils/extensions`)
3434

@@ -56,7 +56,8 @@ A simple Android MVVM pattern example and template.
5656
- `SharedPref`
5757
- `AlarmUtils`
5858
- `LocationProviderUtilClient`
59-
- `Event` Class
59+
- `Event` Class: Get notified for identical values in LiveData, Channel, Flow etc.
60+
- `ignoreCrash { }`: Ignore exceptions for a block.
6061

6162
## Todo
6263

app/build.gradle

Lines changed: 98 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ plugins {
1010
}
1111

1212
android {
13-
compileSdkVersion 31
14-
buildToolsVersion "31.0.0"
13+
namespace 'org.imaginativeworld.simplemvvm'
14+
compileSdkVersion 33
15+
buildToolsVersion "33.0.0"
1516

1617
defaultConfig {
1718
applicationId "org.imaginativeworld.simplemvvm"
1819
minSdkVersion 21
19-
targetSdkVersion 31
20+
targetSdkVersion 33
2021
versionCode 1
2122
versionName "1.0.0.000000" // Major.Minor.Patch.YYMMDD
2223
vectorDrawables.useSupportLibrary = true
@@ -25,25 +26,50 @@ android {
2526

2627
javaCompileOptions {
2728
annotationProcessorOptions {
28-
arguments += [
29-
"room.schemaLocation" : "$projectDir/schemas".toString(),
30-
"room.incremental" : "true",
31-
"room.expandProjection": "true"
32-
]
29+
arguments += ["room.schemaLocation" : "$projectDir/schemas".toString(),
30+
"room.incremental" : "true",
31+
"room.expandProjection": "true"]
3332
}
3433
}
34+
signingConfig signingConfigs.debug
3535
}
3636

3737
buildTypes {
38-
debug {
38+
local { // Local
39+
initWith debug
40+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
41+
42+
loadConfigurationProperties it, "config/internal.properties"
43+
44+
matchingFallbacks = ['debug']
45+
}
46+
47+
debug { // Development
3948
debuggable true
49+
minifyEnabled false
4050
applicationIdSuffix ".debug"
4151
versionNameSuffix "-debug"
52+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
53+
54+
loadConfigurationProperties it, "config/development.properties"
55+
}
56+
57+
staging { // Staging
58+
initWith debug
59+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
60+
61+
loadConfigurationProperties it, "config/staging.properties"
62+
63+
matchingFallbacks = ['release']
4264
}
43-
release {
65+
66+
release { // Production
67+
debuggable false
4468
minifyEnabled true
4569
shrinkResources true
46-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
70+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
71+
72+
loadConfigurationProperties it, "config/release.properties"
4773
}
4874
}
4975

@@ -68,16 +94,15 @@ android {
6894

6995
kotlinOptions {
7096
jvmTarget = "1.8"
71-
useIR = true
7297
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
7398
freeCompilerArgs += "-Xallow-jvm-ir-dependencies"
7499
// Enable experimental coroutines APIs, including Flow
75100
freeCompilerArgs += '-Xopt-in=kotlin.Experimental'
76101
}
77102

78103
buildFeatures {
79-
viewBinding = true
80-
dataBinding = true
104+
viewBinding true
105+
dataBinding true
81106

82107
// Disable unused AGP features
83108
// buildConfig false
@@ -86,63 +111,72 @@ android {
86111
resValues false
87112
shaders false
88113
}
114+
115+
signingConfigs {
116+
debug {
117+
storeFile file('../debug.keystore')
118+
storePassword 'android'
119+
keyAlias 'androiddebugkey'
120+
keyPassword 'android'
121+
}
122+
}
89123
}
90124

91125
dependencies {
92126
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
93-
implementation 'androidx.appcompat:appcompat:1.3.1'
94-
implementation 'androidx.core:core-ktx:1.6.0'
95-
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
127+
implementation 'androidx.appcompat:appcompat:1.6.1'
128+
implementation 'androidx.core:core-ktx:1.9.0'
129+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
96130

97131
testImplementation 'junit:junit:4.13.2'
98-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
99-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
132+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
133+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
100134

101135
// Material Design
102-
implementation 'com.google.android.material:material:1.4.0'
136+
implementation 'com.google.android.material:material:1.8.0'
103137

104138
// Retrofit
105139
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
106-
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
140+
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
107141

108142
// Moshi
109143
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
110-
implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
111-
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.12.0"
144+
implementation "com.squareup.moshi:moshi-kotlin:1.14.0"
145+
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.14.0"
112146

113147
// Gson
114-
implementation 'com.google.code.gson:gson:2.8.7'
148+
implementation 'com.google.code.gson:gson:2.10.1'
115149

116150
// ViewModel and LiveData
117151
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
118152
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
119-
implementation "androidx.lifecycle:lifecycle-common-java8:2.3.1"
153+
implementation "androidx.lifecycle:lifecycle-common:$lifecycle_version"
120154
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
121155

122156
// Kotlin Coroutines
123-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1"
124-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1"
157+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
158+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
125159

126160
// Room Persistence Library
127-
implementation "androidx.room:room-runtime:2.3.0"
128-
kapt "androidx.room:room-compiler:2.3.0"
161+
implementation "androidx.room:room-runtime:$room_version"
162+
kapt "androidx.room:room-compiler:$room_version"
129163

130164
// Room: Kotlin Extensions and Coroutines support for Room
131-
implementation "androidx.room:room-ktx:2.3.0"
165+
implementation "androidx.room:room-ktx:$room_version"
132166

133167
// Android Navigation Architecture
134-
implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
135-
implementation "androidx.navigation:navigation-ui-ktx:2.3.5"
168+
implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
169+
implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
136170

137171
// Glide
138-
implementation 'com.github.bumptech.glide:glide:4.12.0'
139-
kapt 'com.github.bumptech.glide:compiler:4.12.0'
172+
implementation 'com.github.bumptech.glide:glide:4.15.1'
173+
kapt 'com.github.bumptech.glide:compiler:4.15.1'
140174

141175
// Paging
142-
implementation "androidx.paging:paging-runtime-ktx:3.0.1"
176+
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
143177

144178
// Permission
145-
implementation 'com.karumi:dexter:6.2.2'
179+
implementation 'com.karumi:dexter:6.2.3'
146180

147181
// Timber
148182
implementation 'com.jakewharton.timber:timber:5.0.1'
@@ -155,17 +189,17 @@ dependencies {
155189
implementation 'com.facebook.shimmer:shimmer:0.5.0'
156190

157191
// Firebase BoM
158-
implementation platform('com.google.firebase:firebase-bom:28.2.0')
192+
implementation platform('com.google.firebase:firebase-bom:31.2.3')
159193

160194
// Firebase Libraries
161195
implementation 'com.google.firebase:firebase-analytics-ktx'
162196
implementation 'com.google.firebase:firebase-messaging-ktx'
163197

164198
// Maps
165-
implementation 'com.google.android.gms:play-services-maps:17.0.1'
199+
implementation 'com.google.android.gms:play-services-maps:18.1.0'
166200

167201
// Location
168-
implementation 'com.google.android.gms:play-services-location:18.0.0'
202+
implementation 'com.google.android.gms:play-services-location:21.0.1'
169203

170204
// Image compressor
171205
implementation 'id.zelory:compressor:3.0.1'
@@ -174,16 +208,28 @@ dependencies {
174208
implementation 'org.imaginativeworld.oopsnointernet:oopsnointernet:2.0.0'
175209

176210
// Image Carousel
177-
implementation "org.imaginativeworld.whynotimagecarousel:whynotimagecarousel:2.0.2"
211+
implementation "org.imaginativeworld.whynotimagecarousel:whynotimagecarousel:2.1.0"
178212

179213
// OneSignal SDK
180-
implementation 'com.onesignal:OneSignal:4.5.1'
214+
implementation 'com.onesignal:OneSignal:4.8.5'
181215

182216
// Coil
183-
implementation("io.coil-kt:coil:1.3.2")
217+
implementation("io.coil-kt:coil:2.2.2")
184218

185219
// Palette
186220
implementation 'androidx.palette:palette-ktx:1.0.0'
221+
222+
// Markdown
223+
implementation "io.noties.markwon:core:$markwon_version"
224+
implementation "io.noties.markwon:ext-latex:$markwon_version"
225+
implementation "io.noties.markwon:inline-parser:$markwon_version"
226+
227+
// Latex
228+
implementation "ru.noties:jlatexmath-android:$jlatexmath_version"
229+
// for Cyrillic symbols
230+
implementation "ru.noties:jlatexmath-android-font-cyrillic:$jlatexmath_version"
231+
// for Greek symbols
232+
implementation "ru.noties:jlatexmath-android-font-greek:$jlatexmath_version"
187233
}
188234

189235
// Workaround for OneSignal from:
@@ -194,4 +240,14 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
194240
kotlinOptions {
195241
jvmTarget = "1.8"
196242
}
243+
}
244+
245+
/**
246+
* Load properties from configuration file.
247+
*/
248+
def loadConfigurationProperties(buildType, String fileLocation) {
249+
Properties properties = new Properties()
250+
properties.load(project.rootProject.file(fileLocation).newDataInputStream())
251+
252+
buildType.buildConfigField "String", "BASE_URL", "\"${properties.getProperty("baseUrl")}\""
197253
}

app/schemas/org.imaginativeworld.simplemvvm.db.AppDatabase/1.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"formatVersion": 1,
33
"database": {
44
"version": 1,
5-
"identityHash": "25c3d3b313b6c2aaf6ca0d581f9926e8",
5+
"identityHash": "57b1ed91726ddfe1883b04ee15d1bb82",
66
"entities": [
77
{
88
"tableName": "tbl_user",
9-
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL, `phone` TEXT NOT NULL, `image` TEXT)",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL, `phone` TEXT NOT NULL, `image` TEXT, `isFav` INTEGER NOT NULL)",
1010
"fields": [
1111
{
1212
"fieldPath": "id",
@@ -31,6 +31,12 @@
3131
"columnName": "image",
3232
"affinity": "TEXT",
3333
"notNull": false
34+
},
35+
{
36+
"fieldPath": "isFav",
37+
"columnName": "isFav",
38+
"affinity": "INTEGER",
39+
"notNull": true
3440
}
3541
],
3642
"primaryKey": {
@@ -46,7 +52,7 @@
4652
"views": [],
4753
"setupQueries": [
4854
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
49-
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '25c3d3b313b6c2aaf6ca0d581f9926e8')"
55+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '57b1ed91726ddfe1883b04ee15d1bb82')"
5056
]
5157
}
5258
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?><!-- Bismillahir Rahmanir Rahim -->
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="org.imaginativeworld.simplemvvm">
3+
xmlns:tools="http://schemas.android.com/tools">
54

65
<uses-permission android:name="android.permission.INTERNET" />
76
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

0 commit comments

Comments
 (0)