Skip to content

Commit ada23a5

Browse files
Merge pull request #9 from ImaginativeShohag/dev
Dev
2 parents 5596586 + 608a8b4 commit ada23a5

File tree

67 files changed

+1409
-579
lines changed

Some content is hidden

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

67 files changed

+1409
-579
lines changed

README.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Simple MVVM
22

3-
A simple Android MVVM pattern example and template
3+
A simple Android MVVM pattern example and template.
4+
5+
## Android Studio Version
6+
7+
- Android Studio Arctic Fox | 2020.3.1 Patch 2
48

59
## Used Components/Libraries
610

@@ -16,15 +20,29 @@ A simple Android MVVM pattern example and template
1620
- Timber (https://github.com/JakeWharton/timber)
1721
- Custom Fonts (https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml)
1822
- Shimmer for Android (https://github.com/facebook/shimmer-android)
19-
- Dagger (https://github.com/google/dagger)
20-
- Paging (https://developer.android.com/topic/libraries/architecture/paging)
23+
- Hilt (https://dagger.dev/hilt/)
24+
- Paging 3 (https://developer.android.com/topic/libraries/architecture/paging)
2125
- Dexter (https://github.com/Karumi/Dexter) **(coming soon...)**
2226

2327
## Others
2428

2529
- Build variant (https://developer.android.com/studio/build/build-variants)
2630
- Custom Snackbar
27-
- Dark Mode (Initially Implemented)
31+
- Dark Mode
32+
33+
## Extension Functions (see `utils/extensions`)
34+
35+
- DateTime
36+
- Dialog
37+
- Dimension
38+
- Flow
39+
- General Spinner
40+
- Miscellaneous: show/hide keyboard, download file, open permission settings, open url, send mail
41+
etc.
42+
- Retrofit
43+
- Snackbar
44+
- String
45+
- Toast
2846

2947
## Common Binding Adapters
3048

@@ -33,10 +51,20 @@ A simple Android MVVM pattern example and template
3351
- ImageView
3452
- TextView (for Date() to formatted date-time)
3553

54+
# Utilities
55+
56+
- `SharedPref`
57+
- `AlarmUtils`
58+
- `LocationProviderUtilClient`
59+
- `Event` Class
60+
3661
## Todo
3762

3863
- Add New Post
39-
- Login
40-
- Registration
41-
- Migrate to Hilt
42-
- Migrate to Paging 3
64+
- Demo Login
65+
- Demo Registration
66+
- OneSignal integration
67+
- Splash (Introduced in Android S)
68+
- Testing
69+
- Example of LocationProviderUtilClient
70+
- AdUtils from Ticket Sheba

app/build.gradle

Lines changed: 83 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
apply plugin: 'com.android.application'
2-
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-parcelize'
4-
apply plugin: 'kotlin-kapt'
5-
6-
// Navigation Component: Safe Args
7-
apply plugin: "androidx.navigation.safeargs"
8-
9-
apply plugin: 'com.google.gms.google-services'
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
id 'kotlin-parcelize'
5+
id 'kotlin-kapt'
6+
id 'androidx.navigation.safeargs'
7+
id 'com.google.gms.google-services'
8+
id 'com.google.firebase.crashlytics'
9+
id 'dagger.hilt.android.plugin'
10+
}
1011

1112
android {
12-
compileSdkVersion 30
13-
buildToolsVersion "30.0.3"
13+
compileSdkVersion 31
14+
buildToolsVersion "31.0.0"
1415

1516
defaultConfig {
1617
applicationId "org.imaginativeworld.simplemvvm"
1718
minSdkVersion 21
18-
targetSdkVersion 30
19+
targetSdkVersion 31
1920
versionCode 1
20-
versionName "1.0.000000" // Major.Minor.YYMMDD
21+
versionName "1.0.0.000000" // Major.Minor.Patch.YYMMDD
22+
vectorDrawables.useSupportLibrary = true
2123

2224
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2325

2426
javaCompileOptions {
2527
annotationProcessorOptions {
26-
arguments = [
28+
arguments += [
2729
"room.schemaLocation" : "$projectDir/schemas".toString(),
2830
"room.incremental" : "true",
2931
"room.expandProjection": "true"
@@ -33,16 +35,16 @@ android {
3335
}
3436

3537
buildTypes {
36-
release {
37-
minifyEnabled true
38-
shrinkResources true
39-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
40-
}
4138
debug {
4239
debuggable true
4340
applicationIdSuffix ".debug"
4441
versionNameSuffix "-debug"
4542
}
43+
release {
44+
minifyEnabled true
45+
shrinkResources true
46+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
47+
}
4648
}
4749

4850
// flavorDimensions "feature"
@@ -66,38 +68,60 @@ android {
6668

6769
kotlinOptions {
6870
jvmTarget = "1.8"
71+
useIR = true
72+
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
73+
freeCompilerArgs += "-Xallow-jvm-ir-dependencies"
74+
// Enable experimental coroutines APIs, including Flow
75+
freeCompilerArgs += '-Xopt-in=kotlin.Experimental'
6976
}
7077

7178
buildFeatures {
7279
viewBinding = true
7380
dataBinding = true
81+
82+
// Disable unused AGP features
83+
// buildConfig false
84+
aidl false
85+
renderScript false
86+
resValues false
87+
shaders false
7488
}
7589
}
7690

7791
dependencies {
78-
implementation fileTree(dir: 'libs', include: ['*.jar'])
7992
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
80-
implementation 'androidx.appcompat:appcompat:1.3.0'
81-
implementation 'androidx.core:core-ktx:1.5.0'
82-
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
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'
96+
8397
testImplementation 'junit:junit:4.13.2'
84-
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
85-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
98+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
99+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
86100

87-
// Retrofit and Moshi
101+
// Material Design
102+
implementation 'com.google.android.material:material:1.4.0'
103+
104+
// Retrofit
88105
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
89-
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
90106
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
107+
108+
// Moshi
109+
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
91110
implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
92111
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.12.0"
93112

113+
// Gson
114+
implementation 'com.google.code.gson:gson:2.8.7'
115+
94116
// ViewModel and LiveData
95-
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
96-
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
117+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
118+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
97119
implementation "androidx.lifecycle:lifecycle-common-java8:2.3.1"
120+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
98121

99-
// Material Design
100-
implementation 'com.google.android.material:material:1.3.0'
122+
// Kotlin Coroutines
123+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1"
124+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1"
101125

102126
// Room Persistence Library
103127
implementation "androidx.room:room-runtime:2.3.0"
@@ -110,40 +134,28 @@ dependencies {
110134
implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
111135
implementation "androidx.navigation:navigation-ui-ktx:2.3.5"
112136

113-
// Kotlin Coroutines
114-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
115-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0"
116-
// Lifecycles only (without ViewModel or LiveData)
117-
// implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
118-
119137
// Glide
120138
implementation 'com.github.bumptech.glide:glide:4.12.0'
121139
kapt 'com.github.bumptech.glide:compiler:4.12.0'
122140

123141
// Paging
124-
implementation "androidx.paging:paging-runtime-ktx:3.0.0"
125-
126-
// No Internet Library
127-
implementation 'org.imaginativeworld.oopsnointernet:oopsnointernet:2.0.0'
142+
implementation "androidx.paging:paging-runtime-ktx:3.0.1"
128143

129144
// Permission
130145
implementation 'com.karumi:dexter:6.2.2'
131146

132147
// Timber
133-
implementation 'com.jakewharton.timber:timber:4.7.1'
148+
implementation 'com.jakewharton.timber:timber:5.0.1'
134149

135-
// Dagger
136-
implementation 'com.google.dagger:dagger:2.36'
137-
kapt 'com.google.dagger:dagger-compiler:2.36'
138-
139-
implementation 'com.google.dagger:dagger-android:2.36'
140-
kapt 'com.google.dagger:dagger-android-processor:2.36'
150+
// Hilt
151+
implementation "com.google.dagger:hilt-android:$hilt_version"
152+
kapt "com.google.dagger:hilt-compiler:$hilt_version"
141153

142154
// Shimmer
143155
implementation 'com.facebook.shimmer:shimmer:0.5.0'
144156

145157
// Firebase BoM
146-
implementation platform('com.google.firebase:firebase-bom:26.1.0')
158+
implementation platform('com.google.firebase:firebase-bom:28.2.0')
147159

148160
// Firebase Libraries
149161
implementation 'com.google.firebase:firebase-analytics-ktx'
@@ -158,6 +170,28 @@ dependencies {
158170
// Image compressor
159171
implementation 'id.zelory:compressor:3.0.1'
160172

173+
// No Internet Library
174+
implementation 'org.imaginativeworld.oopsnointernet:oopsnointernet:2.0.0'
175+
161176
// Image Carousel
162177
implementation "org.imaginativeworld.whynotimagecarousel:whynotimagecarousel:2.0.2"
178+
179+
// OneSignal SDK
180+
implementation 'com.onesignal:OneSignal:4.5.1'
181+
182+
// Coil
183+
implementation("io.coil-kt:coil:1.3.2")
184+
185+
// Palette
186+
implementation 'androidx.palette:palette-ktx:1.0.0'
163187
}
188+
189+
// Workaround for OneSignal from:
190+
// https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/37#issuecomment-391983620
191+
googleServices { disableVersionCheck = true }
192+
193+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
194+
kotlinOptions {
195+
jvmTarget = "1.8"
196+
}
197+
}

app/proguard-rules.pro

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,85 @@
1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
2121
#-renamesourcefileattribute SourceFile
22+
23+
# ----------------------------------------------------------------
24+
# Help Resources:
25+
# - https://proandroiddev.com/android-default-proguard-rules-guide-20058ba7a486
26+
# ----------------------------------------------------------------
27+
28+
# ----------------------------------------------------------------
29+
# Models
30+
# ----------------------------------------------------------------
31+
# Nothing individual so far...
32+
33+
# ----------------------------------------------------------------
34+
# Moshi
35+
# ----------------------------------------------------------------
36+
# Note: Moshi contains minimally required rules for its own internals to work without need for consumers to embed their own.
37+
38+
# ----------------------------------------------------------------
39+
# Parcelable
40+
# ----------------------------------------------------------------
41+
-keepclassmembers class * implements android.os.Parcelable {
42+
public static final ** CREATOR;
43+
}
44+
45+
# ----------------------------------------------------------------
46+
# Maps
47+
# ----------------------------------------------------------------
48+
# Link: https://developers.google.com/maps/documentation/android-sdk/v3-client-migration
49+
-keep,allowoptimization class com.google.android.libraries.maps.** { *; }
50+
51+
# ----------------------------------------------------------------
52+
# Retrofit
53+
# Source: https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro
54+
# ----------------------------------------------------------------
55+
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
56+
# EnclosingMethod is required to use InnerClasses.
57+
-keepattributes Signature, InnerClasses, EnclosingMethod
58+
59+
# Retrofit does reflection on method and parameter annotations.
60+
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
61+
62+
# Keep annotation default values (e.g., retrofit2.http.Field.encoded).
63+
-keepattributes AnnotationDefault
64+
65+
# Retain service method parameters when optimizing.
66+
-keepclassmembers,allowshrinking,allowobfuscation interface * {
67+
@retrofit2.http.* <methods>;
68+
}
69+
70+
# Ignore annotation used for build tooling.
71+
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
72+
73+
# Ignore JSR 305 annotations for embedding nullability information.
74+
-dontwarn javax.annotation.**
75+
76+
# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
77+
-dontwarn kotlin.Unit
78+
79+
# Top-level functions that can only be used by Kotlin.
80+
-dontwarn retrofit2.KotlinExtensions
81+
-dontwarn retrofit2.KotlinExtensions$*
82+
83+
# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
84+
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
85+
-if interface * { @retrofit2.http.* <methods>; }
86+
-keep,allowobfuscation interface <1>
87+
88+
# Keep generic signature of Call (R8 full mode strips signatures from non-kept items).
89+
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
90+
91+
# ----------------------------------------------------------------
92+
# OkHttp
93+
# Source: https://square.github.io/okhttp/r8_proguard/
94+
# ----------------------------------------------------------------
95+
# Note: If you use OkHttp as a dependency in an Android project which uses R8 as a default compiler you don’t have to do anything.
96+
97+
# ----------------------------------------------------------------
98+
# okio
99+
# Source: https://square.github.io/okio/#r8-proguard
100+
# ----------------------------------------------------------------
101+
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
102+
-dontwarn org.codehaus.mojo.animal_sniffer.*
103+

0 commit comments

Comments
 (0)