├── .gitignore ├── .idea └── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── ekar │ │ └── assignment │ │ └── ExampleInstrumentedTest.kt │ ├── debug │ └── res │ │ └── values │ │ └── google_maps_api.xml │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── ekar │ │ │ └── assignment │ │ │ ├── EkarApp.kt │ │ │ ├── core │ │ │ ├── base │ │ │ │ └── BaseViewModel.kt │ │ │ ├── domain │ │ │ │ ├── Mapper.kt │ │ │ │ └── UseCase.kt │ │ │ └── network │ │ │ │ ├── BaseRepository.kt │ │ │ │ └── RestResult.kt │ │ │ ├── data │ │ │ ├── api │ │ │ │ └── ApiService.kt │ │ │ ├── mock │ │ │ │ └── DummyLocationProvider.kt │ │ │ ├── model │ │ │ │ ├── request │ │ │ │ │ └── CarDetailRequest.kt │ │ │ │ └── response │ │ │ │ │ └── CarDetailResponse.kt │ │ │ └── repository │ │ │ │ └── CarDetailRepository.kt │ │ │ ├── di │ │ │ ├── NetworkModule.kt │ │ │ ├── RepositoryModule.kt │ │ │ ├── ServiceModule.kt │ │ │ ├── UseCaseModule.kt │ │ │ └── coroutine │ │ │ │ ├── CoroutineModule.kt │ │ │ │ ├── CoroutineThread.kt │ │ │ │ └── CoroutineThreadImpl.kt │ │ │ ├── domain │ │ │ ├── decider │ │ │ │ └── CarAttributeDecider.kt │ │ │ ├── mapper │ │ │ │ └── CarSpecUIModelMapper.kt │ │ │ ├── uimodel │ │ │ │ └── CarDetailUIModel.kt │ │ │ └── usecase │ │ │ │ └── GetCarDetail.kt │ │ │ ├── ui │ │ │ ├── Screen.kt │ │ │ ├── activity │ │ │ │ └── MainActivity.kt │ │ │ ├── map │ │ │ │ └── MapScreen.kt │ │ │ ├── splash │ │ │ │ ├── SplashScreen.kt │ │ │ │ └── SplashViewModel.kt │ │ │ ├── theme │ │ │ │ ├── Color.kt │ │ │ │ ├── Padding.kt │ │ │ │ ├── Shapes.kt │ │ │ │ ├── Theme.kt │ │ │ │ └── Type.kt │ │ │ └── vehicle │ │ │ │ ├── VehicleScreen.kt │ │ │ │ └── VehicleViewModel.kt │ │ │ └── uicomponent │ │ │ ├── ButtonType1.kt │ │ │ ├── ButtonType2.kt │ │ │ ├── Dropdown.kt │ │ │ ├── LoadingView.kt │ │ │ ├── ShowCaseLabelType1.kt │ │ │ ├── ShowcaseLabelType2.kt │ │ │ └── map │ │ │ └── MapUtils.kt │ └── res │ │ ├── drawable-v24 │ │ ├── ekar_car.png │ │ ├── ekar_logo.png │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── layout_map.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ ├── style.xml │ │ └── themes.xml │ ├── release │ └── res │ │ └── values │ │ └── google_maps_api.xml │ └── test │ └── java │ └── com │ └── ekar │ └── assignment │ └── ExampleUnitTest.kt ├── build.gradle ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── java │ ├── Config.kt │ ├── Libs.kt │ └── Versions.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/android,androidstudio,java,kotlin,macos,windows 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=android,androidstudio,java,kotlin,macos,windows 4 | 5 | ### Android ### 6 | # Built application files 7 | *.apk 8 | *.aar 9 | *.ap_ 10 | *.aab 11 | 12 | # Files for the ART/Dalvik VM 13 | *.dex 14 | 15 | # Java class files 16 | *.class 17 | 18 | # Generated files 19 | bin/ 20 | gen/ 21 | out/ 22 | # Uncomment the following line in case you need and you don't have the release build type files in your app 23 | # release/ 24 | 25 | # Gradle files 26 | .gradle/ 27 | build/ 28 | 29 | # Local configuration file (sdk path, etc) 30 | local.properties 31 | 32 | # Proguard folder generated by Eclipse 33 | proguard/ 34 | 35 | # Log Files 36 | *.log 37 | 38 | # Android Studio Navigation editor temp files 39 | .navigation/ 40 | 41 | # Android Studio captures folder 42 | captures/ 43 | 44 | # IntelliJ 45 | *.iml 46 | .idea/workspace.xml 47 | .idea/tasks.xml 48 | .idea/gradle.xml 49 | .idea/assetWizardSettings.xml 50 | .idea/dictionaries 51 | .idea/libraries 52 | # Android Studio 3 in .gitignore file. 53 | .idea/caches 54 | .idea/modules.xml 55 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 56 | .idea/navEditor.xml 57 | 58 | # Keystore files 59 | # Uncomment the following lines if you do not want to check your keystore files in. 60 | #*.jks 61 | #*.keystore 62 | 63 | # External native build folder generated in Android Studio 2.2 and later 64 | .externalNativeBuild 65 | .cxx/ 66 | 67 | # Google Services (e.g. APIs or Firebase) 68 | # google-services.json 69 | 70 | # Freeline 71 | freeline.py 72 | freeline/ 73 | freeline_project_description.json 74 | 75 | # fastlane 76 | fastlane/report.xml 77 | fastlane/Preview.html 78 | fastlane/screenshots 79 | fastlane/test_output 80 | fastlane/readme.md 81 | 82 | # Version control 83 | vcs.xml 84 | 85 | # lint 86 | lint/intermediates/ 87 | lint/generated/ 88 | lint/outputs/ 89 | lint/tmp/ 90 | # lint/reports/ 91 | 92 | ### Android Patch ### 93 | gen-external-apklibs 94 | output.json 95 | 96 | # Replacement of .externalNativeBuild directories introduced 97 | # with Android Studio 3.5. 98 | 99 | ### Java ### 100 | # Compiled class file 101 | 102 | # Log file 103 | 104 | # BlueJ files 105 | *.ctxt 106 | 107 | # Mobile Tools for Java (J2ME) 108 | .mtj.tmp/ 109 | 110 | # Package Files # 111 | *.jar 112 | *.war 113 | *.nar 114 | *.ear 115 | *.zip 116 | *.tar.gz 117 | *.rar 118 | 119 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 120 | hs_err_pid* 121 | 122 | ### Kotlin ### 123 | # Compiled class file 124 | 125 | # Log file 126 | 127 | # BlueJ files 128 | 129 | # Mobile Tools for Java (J2ME) 130 | 131 | # Package Files # 132 | 133 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 134 | 135 | ### macOS ### 136 | # General 137 | .DS_Store 138 | .AppleDouble 139 | .LSOverride 140 | 141 | # Icon must end with two \r 142 | Icon 143 | 144 | 145 | # Thumbnails 146 | ._* 147 | 148 | # Files that might appear in the root of a volume 149 | .DocumentRevisions-V100 150 | .fseventsd 151 | .Spotlight-V100 152 | .TemporaryItems 153 | .Trashes 154 | .VolumeIcon.icns 155 | .com.apple.timemachine.donotpresent 156 | 157 | # Directories potentially created on remote AFP share 158 | .AppleDB 159 | .AppleDesktop 160 | Network Trash Folder 161 | Temporary Items 162 | .apdisk 163 | 164 | ### Windows ### 165 | # Windows thumbnail cache files 166 | Thumbs.db 167 | Thumbs.db:encryptable 168 | ehthumbs.db 169 | ehthumbs_vista.db 170 | 171 | # Dump file 172 | *.stackdump 173 | 174 | # Folder config file 175 | [Dd]esktop.ini 176 | 177 | # Recycle Bin used on file shares 178 | $RECYCLE.BIN/ 179 | 180 | # Windows Installer files 181 | *.cab 182 | *.msi 183 | *.msix 184 | *.msm 185 | *.msp 186 | 187 | # Windows shortcuts 188 | *.lnk 189 | 190 | ### AndroidStudio ### 191 | # Covers files to be ignored for android development using Android Studio. 192 | 193 | # Built application files 194 | 195 | # Files for the ART/Dalvik VM 196 | 197 | # Java class files 198 | 199 | # Generated files 200 | 201 | # Gradle files 202 | .gradle 203 | 204 | # Signing files 205 | .signing/ 206 | 207 | # Local configuration file (sdk path, etc) 208 | 209 | # Proguard folder generated by Eclipse 210 | 211 | # Log Files 212 | 213 | # Android Studio 214 | /*/build/ 215 | /*/local.properties 216 | /*/out 217 | /*/*/build 218 | /*/*/production 219 | *.ipr 220 | *~ 221 | *.swp 222 | 223 | # Keystore files 224 | *.jks 225 | *.keystore 226 | 227 | # Google Services (e.g. APIs or Firebase) 228 | # google-services.json 229 | 230 | # Android Patch 231 | 232 | # External native build folder generated in Android Studio 2.2 and later 233 | 234 | # NDK 235 | obj/ 236 | 237 | # IntelliJ IDEA 238 | *.iws 239 | /out/ 240 | 241 | # User-specific configurations 242 | .idea/caches/ 243 | .idea/libraries/ 244 | .idea/shelf/ 245 | .idea/.name 246 | .idea/compiler.xml 247 | .idea/copyright/profiles_settings.xml 248 | .idea/encodings.xml 249 | .idea/misc.xml 250 | .idea/scopes/scope_settings.xml 251 | .idea/vcs.xml 252 | .idea/jsLibraryMappings.xml 253 | .idea/datasources.xml 254 | .idea/dataSources.ids 255 | .idea/sqlDataSources.xml 256 | .idea/dynamic.xml 257 | .idea/uiDesigner.xml 258 | .idea/jarRepositories.xml 259 | 260 | # OS-specific files 261 | .DS_Store? 262 | 263 | # Legacy Eclipse project files 264 | .classpath 265 | .project 266 | .cproject 267 | .settings/ 268 | 269 | # Mobile Tools for Java (J2ME) 270 | 271 | # Package Files # 272 | 273 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) 274 | 275 | ## Plugin-specific files: 276 | 277 | # mpeltonen/sbt-idea plugin 278 | .idea_modules/ 279 | 280 | # JIRA plugin 281 | atlassian-ide-plugin.xml 282 | 283 | # Mongo Explorer plugin 284 | .idea/mongoSettings.xml 285 | 286 | # Crashlytics plugin (for Android Studio and IntelliJ) 287 | com_crashlytics_export_strings.xml 288 | crashlytics.properties 289 | crashlytics-build.properties 290 | fabric.properties 291 | 292 | ### AndroidStudio Patch ### 293 | 294 | !/gradle/wrapper/gradle-wrapper.jar 295 | 296 | # End of https://www.toptal.com/developers/gitignore/api/android,androidstudio,java,kotlin,macos,windows -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EkarAssignment 2 | Ekar Assignment for Mobile Engineers 3 | 4 | ## UI 5 | App consist of 3 different fragments and 1 root activity. Activity holds a container layout in order to manage fragments which will be controlled by navigation component. 6 | 7 | Fragments : 8 | * SplashScreen 9 | * MapScreen 10 | * VehicleScreen 11 | 12 | ## Screenshots 13 | 14 |

15 | 16 | 17 | 18 |

19 | 20 | ## App Flow 21 | #### SplashScreen 22 | App opens with splash screen fragment and navigate to the map screen after showing the ekar logo to the user for 2 seconds. 23 | 24 | #### MapScreen 25 | Map Screen is the main part of the app. In first launch, random markers are placed on the map around Dubai zone. Features is listed below: 26 | * Different colored markers placed in map. 27 | * Click marker to navigate vehicle screen. 28 | 29 | #### VehicleScreen 30 | This screen responsible for showing all details of vehicle such as price, standard seating, booking fee and the other things. 31 | 32 | ## Architecture 33 | This app adopts Clean Architecture behaviour. Here is the package structure: 34 | 35 | #### Core 36 | It is the package that contains all the common and base classes used within the application. 37 | Extensions, deciders, utils and base classes are included in this package. 38 | 39 | #### Data 40 | Data package should include response models, data source and api methods. It shouldn't know any logic. 41 | 42 | #### UI 43 | Ui like a feature. It contains Fragments, view models and feature related classes like a domains, mappers and ui models. 44 | Make sure that all classes here are specific to the this feature. If it is a class that is also used in other features, it should be moved to the common package. 45 | 46 | #### Di 47 | This package may actually be inside the common module. But I prefer to carry outside of core package to be more visible. 48 | 49 | #### Ui-Component 50 | In large projects, we need to use a view component in more than one place. So i moved common view components under ui-component package. 51 | 52 | ## Tech Stack 53 | * [Kotlin](https://kotlinlang.org/) , [Coroutines](https://github.com/Kotlin/kotlinx.coroutines) , [Flow](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/) 54 | * [Dagger-Hilt](https://developer.android.com/training/dependency-injection/hilt-android) - Dependency Injection 55 | * [MVVM Architecture](https://developer.android.com/jetpack/guide) - Modern, maintainable, and Google suggested app architecture 56 | * [Retrofit2 & OkHttp3](https://github.com/square/retrofit) 57 | * [Gson](https://github.com/google/gson) 58 | * [Navigation Component](https://developer.android.com/guide/navigation) - Single activity multiple fragments approach 59 | 60 | 61 | ## TODOs and Improvements 62 | - UI test. 63 | - Better Design 64 | - Unit tests for different screnios 65 | - Implementation of static code analysis tool(ktlint or detekt) 66 | - Styling definitions for textviews and buttons etc. 67 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | plugins { 3 | id 'com.android.application' 4 | id 'kotlin-android' 5 | id 'kotlin-kapt' 6 | id 'dagger.hilt.android.plugin' 7 | } 8 | 9 | android { 10 | compileSdk Config.compileSdkVersion 11 | 12 | defaultConfig { 13 | applicationId Config.applicationId 14 | minSdk Config.minSdkVersion 15 | targetSdk Config.targetSdkVersion 16 | versionCode Config.versionCode 17 | versionName Config.versionName 18 | 19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 20 | } 21 | 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | compileOptions { 29 | sourceCompatibility JavaVersion.VERSION_1_8 30 | targetCompatibility JavaVersion.VERSION_1_8 31 | } 32 | 33 | buildFeatures { 34 | compose true 35 | viewBinding true 36 | 37 | } 38 | composeOptions { 39 | kotlinCompilerExtensionVersion Versions.compose 40 | kotlinCompilerVersion '1.5.21' 41 | } 42 | 43 | kotlinOptions { 44 | jvmTarget = '1.8' 45 | } 46 | } 47 | 48 | dependencies { 49 | 50 | implementation Libs.coreKtx 51 | implementation Libs.appCompat 52 | implementation Libs.material 53 | 54 | // Lifecycle 55 | implementation Libs.lifecycleViewModel 56 | implementation Libs.lifecycleRuntime 57 | implementation Libs.lifecycleLiveData 58 | 59 | //Retrofit & OkHttp 60 | implementation Libs.converter 61 | implementation Libs.retrofit 62 | implementation Libs.okhttp 63 | implementation Libs.interceptor 64 | 65 | //Coroutines 66 | implementation Libs.coroutinesAndroid 67 | implementation Libs.coroutinesCore 68 | 69 | //Compose 70 | implementation Libs.composeUi 71 | implementation Libs.composeMaterial 72 | implementation Libs.composeToolingPreview 73 | implementation Libs.composeActivity 74 | implementation Libs.composeNavigation 75 | 76 | //Map 77 | implementation Libs.mapKtx 78 | implementation Libs.googleMaps 79 | 80 | //Fragment 81 | implementation Libs.fragment 82 | 83 | //Logging 84 | implementation Libs.timber 85 | 86 | //Hilt 87 | implementation Libs.hiltAndroid 88 | kapt Libs.hiltCompiler 89 | implementation Libs.hiltCompose 90 | 91 | testImplementation Libs.junit 92 | androidTestImplementation Libs.junitExt 93 | androidTestImplementation Libs.espresso 94 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/ekar/assignment/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.ekar.assignment", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/debug/res/values/google_maps_api.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | google_api_key_here 4 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 12 | 13 | 21 | 22 | 30 | 33 | 34 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/EkarApp.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | import timber.log.Timber 6 | 7 | /** 8 | * @author yusuf.onder 9 | * Created on 2.01.2022 10 | */ 11 | @HiltAndroidApp 12 | class EkarApp : Application() { 13 | 14 | override fun onCreate() { 15 | super.onCreate() 16 | setupTimber() 17 | } 18 | 19 | private fun setupTimber(){ 20 | if (BuildConfig.DEBUG) { 21 | Timber.plant(Timber.DebugTree()) 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/core/base/BaseViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.core.base 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 2.01.2022 6 | */ 7 | import androidx.lifecycle.ViewModel 8 | import androidx.lifecycle.viewModelScope 9 | import com.ekar.assignment.core.network.RestResult 10 | import kotlinx.coroutines.flow.Flow 11 | import kotlinx.coroutines.flow.collect 12 | import kotlinx.coroutines.launch 13 | 14 | abstract class BaseViewModel : ViewModel() { 15 | 16 | fun request( 17 | flow: Flow>, 18 | onSuccess: ((data: T) -> Unit)? = null, 19 | onError: ((t: Exception) -> Unit)? = null, 20 | onLoading: (() -> Unit)? = null 21 | ) = viewModelScope.launch { 22 | flow.collect { result -> 23 | when (result) { 24 | is RestResult.Loading -> onLoading?.invoke() 25 | is RestResult.Success -> onSuccess?.invoke(result.data) 26 | is RestResult.Error -> { onError?.invoke(result.exception) } 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/core/domain/Mapper.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.core.domain 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 2.01.2022 6 | */ 7 | interface Mapper { 8 | fun map(input: Input): Output 9 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/core/domain/UseCase.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.core.domain 2 | 3 | import kotlinx.coroutines.flow.Flow 4 | 5 | /** 6 | * @author yusuf.onder 7 | * Created on 2.01.2022 8 | */ 9 | interface UseCase { 10 | suspend operator fun invoke(input: Input): Flow 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/core/network/BaseRepository.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.core.network 2 | 3 | import kotlinx.coroutines.CoroutineDispatcher 4 | import kotlinx.coroutines.Dispatchers 5 | import kotlinx.coroutines.flow.Flow 6 | import kotlinx.coroutines.flow.catch 7 | import kotlinx.coroutines.flow.flow 8 | import kotlinx.coroutines.flow.flowOn 9 | import retrofit2.Response 10 | import java.io.IOException 11 | 12 | /** 13 | * @author yusuf.onder 14 | * Created on 2.01.2022 15 | */ 16 | 17 | abstract class BaseRepository { 18 | 19 | fun safeApiCall( 20 | dispatcher: CoroutineDispatcher = Dispatchers.IO, 21 | call: suspend () -> Response 22 | ): Flow> = 23 | flow { 24 | emit(RestResult.Loading) 25 | val response = call.invoke() 26 | val responseBody = response.body() 27 | if (response.isSuccessful && responseBody != null) { 28 | emit(RestResult.Success(responseBody)) 29 | } else { 30 | val responseError = response.errorBody() 31 | if (responseError != null) { 32 | emit(RestResult.Error(IOException(responseError.toString()))) 33 | } else { 34 | emit(RestResult.Error(IOException("Unknown error"))) 35 | } 36 | } 37 | }.catch { error -> 38 | error.printStackTrace() 39 | emit(RestResult.Error(Exception(error))) 40 | }.flowOn(dispatcher) 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/core/network/RestResult.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.core.network 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 2.01.2022 6 | */ 7 | 8 | sealed class RestResult { 9 | 10 | class Success(val data: T) : RestResult() 11 | 12 | class Error(val exception: Exception) : RestResult() 13 | 14 | object Loading : RestResult() 15 | 16 | fun onSuccess(handler: (T) -> Unit): RestResult = this.also { 17 | if (this is Success) handler(data) 18 | } 19 | 20 | fun onLoading(handler: () -> Unit): RestResult = this.also { 21 | if (this is Loading) handler() 22 | } 23 | 24 | fun onError(handler: (t: Exception) -> Unit): RestResult = this.also { 25 | if (this is Error) handler(exception) 26 | } 27 | 28 | fun getValue(): T? = (this as Success).data 29 | } 30 | 31 | fun RestResult.map(transform: (T) -> R): RestResult { 32 | return when (this) { 33 | is RestResult.Success -> RestResult.Success(transform(data)) 34 | is RestResult.Error -> RestResult.Error(exception) 35 | is RestResult.Loading -> RestResult.Loading 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/data/api/ApiService.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.data.api 2 | 3 | import com.ekar.assignment.data.model.response.CarDetailResponse 4 | import retrofit2.Response 5 | import retrofit2.http.GET 6 | import retrofit2.http.Query 7 | 8 | /** 9 | * @author yusuf.onder 10 | * Created on 2.01.2022 11 | */ 12 | interface ApiService { 13 | 14 | @GET("specs") 15 | suspend fun getSpecs( 16 | @Query("key") key: String, 17 | @Query("vin") vin: String 18 | ): Response 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/data/mock/DummyLocationProvider.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.data.mock 2 | 3 | import com.google.android.libraries.maps.model.LatLng 4 | import kotlin.random.Random 5 | 6 | /** 7 | * @author yusuf.onder 8 | * Created on 2.01.2022 9 | */ 10 | object DummyLocationProvider { 11 | private val dubaiCenter = LatLng(25.276987, 55.296249) 12 | var locationPoints: ArrayList = arrayListOf() 13 | 14 | private const val HUE_RED = 0.0f 15 | private const val HUE_ORANGE = 30.0f 16 | private const val HUE_YELLOW = 60.0f 17 | private const val HUE_GREEN = 120.0f 18 | private const val HUE_BLUE = 240.0f 19 | private val hueColors = listOf(HUE_RED, HUE_ORANGE, HUE_YELLOW, HUE_GREEN, HUE_BLUE) 20 | 21 | init { 22 | fillLocationPoints() 23 | } 24 | 25 | private fun fillLocationPoints() { 26 | repeat(10) { 27 | locationPoints.add( 28 | LocationPoint( 29 | title = "Dubai Point($it)", 30 | latLng = LatLng( 31 | dubaiCenter.latitude + Random.nextDouble(0.1), 32 | dubaiCenter.longitude + Random.nextDouble(0.1) 33 | ), 34 | iconResource = hueColors.random() 35 | ) 36 | ) 37 | } 38 | } 39 | } 40 | 41 | data class LocationPoint(val title: String, val latLng: LatLng, val iconResource: Float) 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/data/model/request/CarDetailRequest.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.data.model.request 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 2.01.2022 6 | */ 7 | data class CarDetailRequest( 8 | val key : String, 9 | val vin : String 10 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/data/model/response/CarDetailResponse.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.data.model.response 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | /** 6 | * @author yusuf.onder 7 | * Created on 2.01.2022 8 | */ 9 | data class CarDetailResponse( 10 | @SerializedName("success") val success: Boolean, 11 | @SerializedName("attributes") val attributes: CarDetailAttributeResponse, 12 | @SerializedName("colors") val colors: List 13 | ) 14 | data class CarDetailColorResponse( 15 | @SerializedName("name") val name: String 16 | ) 17 | data class CarDetailAttributeResponse( 18 | @SerializedName("year") val year: String?, 19 | @SerializedName("model") val model: String?, 20 | @SerializedName("make") val make: String?, 21 | @SerializedName("style") val style: String?, 22 | @SerializedName("delivery_charges") val deliveryCharges: String?, 23 | @SerializedName("standard_seating") val seating: String? 24 | 25 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/data/repository/CarDetailRepository.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.data.repository 2 | 3 | import com.ekar.assignment.core.network.BaseRepository 4 | import com.ekar.assignment.data.api.ApiService 5 | import com.ekar.assignment.data.model.request.CarDetailRequest 6 | import com.ekar.assignment.di.coroutine.CoroutineThread 7 | import javax.inject.Inject 8 | 9 | /** 10 | * @author yusuf.onder 11 | * Created on 2.01.2022 12 | */ 13 | 14 | class CarDetailRepository @Inject constructor( 15 | private val api: ApiService, 16 | private val coroutineThread: CoroutineThread 17 | ) : BaseRepository() { 18 | 19 | suspend operator fun invoke(request: CarDetailRequest) = 20 | safeApiCall(dispatcher = coroutineThread.io) { 21 | api.getSpecs( 22 | key = request.key, 23 | vin = request.vin 24 | ) 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/di/NetworkModule.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.di 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import dagger.hilt.InstallIn 6 | import dagger.hilt.components.SingletonComponent 7 | import okhttp3.OkHttpClient 8 | import okhttp3.logging.HttpLoggingInterceptor 9 | import retrofit2.Retrofit 10 | import retrofit2.converter.gson.GsonConverterFactory 11 | import javax.inject.Singleton 12 | 13 | /** 14 | * @author yusuf.onder 15 | * Created on 2.01.2022 16 | */ 17 | 18 | @[Module InstallIn(SingletonComponent::class)] 19 | object NetworkModule { 20 | 21 | val provideLoggingInterceptor: HttpLoggingInterceptor 22 | @[Provides Singleton] get() = HttpLoggingInterceptor().apply { 23 | level = HttpLoggingInterceptor.Level.BODY 24 | } 25 | 26 | @[Provides Singleton] 27 | fun provideOkHttpClient( 28 | loggingInterceptor: HttpLoggingInterceptor 29 | ): OkHttpClient = 30 | OkHttpClient.Builder().apply { 31 | addInterceptor(loggingInterceptor) 32 | }.build() 33 | 34 | @[Provides Singleton] 35 | fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit { 36 | return Retrofit.Builder() 37 | .client(okHttpClient) 38 | .baseUrl("https://api.carsxe.com/") 39 | .addConverterFactory(GsonConverterFactory.create()) 40 | .build() 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/di/RepositoryModule.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.di 2 | 3 | import com.ekar.assignment.data.api.ApiService 4 | import com.ekar.assignment.data.repository.CarDetailRepository 5 | import com.ekar.assignment.di.coroutine.CoroutineThread 6 | import dagger.Module 7 | import dagger.Provides 8 | import dagger.hilt.InstallIn 9 | import dagger.hilt.android.components.ViewModelComponent 10 | 11 | /** 12 | * @author yusuf.onder 13 | * Created on 2.01.2022 14 | */ 15 | @Module 16 | @InstallIn(ViewModelComponent::class) 17 | object RepositoryModule { 18 | 19 | @[Provides] 20 | fun provideCarDetailRepository( 21 | apiService: ApiService, 22 | coroutineThread: CoroutineThread 23 | ) = CarDetailRepository(apiService, coroutineThread) 24 | 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/di/ServiceModule.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.di 2 | 3 | import com.ekar.assignment.data.api.ApiService 4 | import dagger.Module 5 | import dagger.Provides 6 | import dagger.hilt.InstallIn 7 | import dagger.hilt.components.SingletonComponent 8 | import retrofit2.Retrofit 9 | 10 | /** 11 | * @author yusuf.onder 12 | * Created on 2.01.2022 13 | */ 14 | 15 | @[Module InstallIn(SingletonComponent::class)] 16 | object ServiceModule { 17 | 18 | @[Provides] 19 | fun provideApiService(retrofit: Retrofit): ApiService { 20 | return retrofit.create(ApiService::class.java) 21 | } 22 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/di/UseCaseModule.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.di 2 | 3 | import com.ekar.assignment.data.repository.CarDetailRepository 4 | import com.ekar.assignment.domain.usecase.GetCarDetail 5 | import com.ekar.assignment.domain.mapper.CarSpecUIModelMapper 6 | import dagger.Module 7 | import dagger.Provides 8 | import dagger.hilt.InstallIn 9 | import dagger.hilt.android.components.ViewModelComponent 10 | 11 | /** 12 | * @author yusuf.onder 13 | * Created on 2.01.2022 14 | */ 15 | @[Module InstallIn(ViewModelComponent::class)] 16 | object UseCaseModule { 17 | 18 | @[Provides] 19 | fun provideCarDetailUseCase( 20 | repository: CarDetailRepository, 21 | mapper: CarSpecUIModelMapper 22 | ) = GetCarDetail(repository, mapper) 23 | 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/di/coroutine/CoroutineModule.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.di.coroutine 2 | 3 | import dagger.Binds 4 | import dagger.Module 5 | import dagger.hilt.InstallIn 6 | import dagger.hilt.components.SingletonComponent 7 | import javax.inject.Singleton 8 | 9 | /** 10 | * @author yusuf.onder 11 | * Created on 2.01.2022 12 | */ 13 | @InstallIn(SingletonComponent::class) 14 | @Module 15 | interface CoroutineModule { 16 | 17 | @get:[Binds Singleton] 18 | val CoroutineThreadImpl.coroutineThread: CoroutineThread 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/di/coroutine/CoroutineThread.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.di.coroutine 2 | 3 | import kotlinx.coroutines.CoroutineDispatcher 4 | 5 | /** 6 | * @author yusuf.onder 7 | * Created on 2.01.2022 8 | */ 9 | interface CoroutineThread { 10 | val default: CoroutineDispatcher 11 | val main: CoroutineDispatcher 12 | val io: CoroutineDispatcher 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/di/coroutine/CoroutineThreadImpl.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.di.coroutine 2 | 3 | import kotlinx.coroutines.CoroutineDispatcher 4 | import kotlinx.coroutines.Dispatchers 5 | import javax.inject.Inject 6 | 7 | /** 8 | * @author yusuf.onder 9 | * Created on 2.01.2022 10 | */ 11 | class CoroutineThreadImpl @Inject constructor() : CoroutineThread { 12 | override val default: CoroutineDispatcher = Dispatchers.Default 13 | override val main: CoroutineDispatcher = Dispatchers.Main 14 | override val io: CoroutineDispatcher = Dispatchers.IO 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/domain/decider/CarAttributeDecider.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.domain.decider 2 | 3 | import android.content.Context 4 | import com.ekar.assignment.R 5 | import com.ekar.assignment.data.model.response.CarDetailAttributeResponse 6 | import dagger.hilt.android.qualifiers.ApplicationContext 7 | import java.lang.StringBuilder 8 | import javax.inject.Inject 9 | 10 | /** 11 | * @author yusuf.onder 12 | * Created on 2.01.2022 13 | */ 14 | const val HYPHEN = " - " 15 | 16 | class CarAttributeDecider @Inject constructor(@ApplicationContext private val context: Context) { 17 | 18 | fun provideYear(carAttribute: CarDetailAttributeResponse): String { 19 | val modelBuilder = StringBuilder() 20 | modelBuilder.append(context.getString(R.string.year)) 21 | modelBuilder.append(HYPHEN) 22 | modelBuilder.append(carAttribute.year) 23 | return modelBuilder.toString() 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/domain/mapper/CarSpecUIModelMapper.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.domain.mapper 2 | 3 | import com.ekar.assignment.core.domain.Mapper 4 | import com.ekar.assignment.data.model.response.CarDetailResponse 5 | import com.ekar.assignment.domain.decider.CarAttributeDecider 6 | import com.ekar.assignment.domain.uimodel.CarDetailUIModel 7 | import javax.inject.Inject 8 | 9 | /** 10 | * @author yusuf.onder 11 | * Created on 2.01.2022 12 | */ 13 | class CarSpecUIModelMapper @Inject constructor( 14 | private var decider: CarAttributeDecider 15 | ) : Mapper { 16 | 17 | override fun map(input: CarDetailResponse): CarDetailUIModel { 18 | val attributes = input.attributes 19 | val colors = input.colors.map { it.name } 20 | return CarDetailUIModel( 21 | make = attributes.make.orEmpty(), 22 | style = attributes.style.orEmpty(), 23 | model = attributes.model.orEmpty(), 24 | colors = colors, 25 | deliveryCharges = attributes.deliveryCharges.orEmpty(), 26 | seat = attributes.seating.orEmpty(), 27 | year = attributes.year.orEmpty(), 28 | formattedYear = decider.provideYear(attributes), 29 | //I use mock data for ui because of no required data coming from service 30 | bookingFee = "120", 31 | currency = "AED" 32 | ) 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/domain/uimodel/CarDetailUIModel.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.domain.uimodel 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 2.01.2022 6 | */ 7 | data class CarDetailUIModel( 8 | val make : String, 9 | val model : String, 10 | val style : String, 11 | val colors: List, 12 | val year: String, 13 | val formattedYear : String, 14 | val seat : String, 15 | val deliveryCharges: String, 16 | val bookingFee : String, 17 | val currency: String 18 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/domain/usecase/GetCarDetail.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.domain.usecase 2 | 3 | import com.ekar.assignment.core.domain.UseCase 4 | import com.ekar.assignment.core.network.RestResult 5 | import com.ekar.assignment.core.network.map 6 | import com.ekar.assignment.data.model.request.CarDetailRequest 7 | import com.ekar.assignment.data.repository.CarDetailRepository 8 | import com.ekar.assignment.domain.mapper.CarSpecUIModelMapper 9 | import com.ekar.assignment.domain.uimodel.CarDetailUIModel 10 | import kotlinx.coroutines.flow.map 11 | import javax.inject.Inject 12 | 13 | /** 14 | * @author yusuf.onder 15 | * Created on 2.01.2022 16 | */ 17 | 18 | class GetCarDetail @Inject constructor( 19 | private val repository: CarDetailRepository, 20 | private val mapper: CarSpecUIModelMapper 21 | ) : UseCase> { 22 | 23 | override suspend fun invoke(input: CarDetailRequest) = 24 | repository(input).map { networkState -> 25 | networkState.map { authResponse -> 26 | mapper.map(authResponse) 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/Screen.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui 2 | 3 | import androidx.annotation.StringRes 4 | import com.ekar.assignment.R 5 | 6 | /** 7 | * @author yusuf.onder 8 | * Created on 3.01.2022 9 | */ 10 | sealed class Screen(val route: String, @StringRes val resourceId: Int) { 11 | object Splash : Screen("splash", R.string.splash) 12 | object Map : Screen("map", R.string.map) 13 | object Vehicle : Screen("vehicle", R.string.vehicle) 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/activity/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.activity 2 | 3 | import android.os.Bundle 4 | import androidx.activity.compose.setContent 5 | import androidx.appcompat.app.AppCompatActivity 6 | import androidx.compose.material.* 7 | import androidx.compose.ui.res.stringResource 8 | import androidx.compose.ui.text.input.KeyboardCapitalization.Companion.Characters 9 | import androidx.navigation.compose.NavHost 10 | import androidx.navigation.compose.composable 11 | import androidx.navigation.compose.rememberNavController 12 | import com.ekar.assignment.ui.Screen 13 | import com.ekar.assignment.ui.map.MapScreen 14 | import com.ekar.assignment.ui.splash.Splash 15 | import com.ekar.assignment.ui.theme.EkarAssignmentTheme 16 | import com.ekar.assignment.ui.vehicle.VehicleScreen 17 | import dagger.hilt.android.AndroidEntryPoint 18 | import com.ekar.assignment.R 19 | 20 | @AndroidEntryPoint 21 | class MainActivity : AppCompatActivity() { 22 | 23 | @ExperimentalMaterialApi 24 | override fun onCreate(savedInstanceState: Bundle?) { 25 | super.onCreate(savedInstanceState) 26 | setContent { 27 | EkarAssignmentTheme { 28 | Surface(color = MaterialTheme.colors.background) { 29 | val navController = rememberNavController() 30 | Scaffold( 31 | topBar = { 32 | TopAppBar(title = { 33 | Text(text = stringResource(id = R.string.app_name)) 34 | }) 35 | } 36 | ) { 37 | NavHost(navController, startDestination = Screen.Splash.route) { 38 | composable(Screen.Splash.route) { Splash(navController) } 39 | composable(Screen.Map.route) { MapScreen(navController) } 40 | composable(Screen.Vehicle.route) { VehicleScreen(navController) } 41 | } 42 | } 43 | } 44 | } 45 | } 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/map/MapScreen.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.map 2 | 3 | import androidx.compose.foundation.background 4 | import androidx.compose.foundation.layout.Column 5 | import androidx.compose.foundation.layout.fillMaxHeight 6 | import androidx.compose.foundation.layout.fillMaxWidth 7 | import androidx.compose.runtime.Composable 8 | import androidx.compose.ui.Modifier 9 | import androidx.compose.ui.graphics.Color 10 | import androidx.compose.ui.viewinterop.AndroidView 11 | import androidx.navigation.NavController 12 | import com.ekar.assignment.ui.Screen 13 | import com.ekar.assignment.data.mock.DummyLocationProvider 14 | import com.ekar.assignment.uicomponent.map.rememberMapViewWithLifecycle 15 | import com.google.android.libraries.maps.CameraUpdateFactory 16 | import com.google.android.libraries.maps.model.BitmapDescriptorFactory 17 | import com.google.android.libraries.maps.model.LatLngBounds 18 | import com.google.android.libraries.maps.model.MarkerOptions 19 | import com.google.maps.android.ktx.awaitMap 20 | import kotlinx.coroutines.CoroutineScope 21 | import kotlinx.coroutines.Dispatchers 22 | import kotlinx.coroutines.launch 23 | 24 | /** 25 | * @author yusuf.onder 26 | * Created on 3.01.2022 27 | */ 28 | 29 | @Composable 30 | fun MapScreen(navController: NavController) { 31 | val mapView = rememberMapViewWithLifecycle() 32 | Column( 33 | modifier = Modifier 34 | .fillMaxHeight() 35 | .fillMaxWidth() 36 | .background(Color.White) 37 | ) { 38 | AndroidView({ mapView }) { mapView -> 39 | CoroutineScope(Dispatchers.Main).launch { 40 | val map = mapView.awaitMap() 41 | 42 | map.setOnMarkerClickListener { 43 | navController.navigate(Screen.Vehicle.route) 44 | true 45 | } 46 | val builder = LatLngBounds.Builder() 47 | val locationPoints = DummyLocationProvider.locationPoints 48 | locationPoints.forEach { point -> 49 | builder.include(point.latLng) 50 | val markerOptions = MarkerOptions() 51 | .position(point.latLng) 52 | .title(point.title) 53 | .icon(BitmapDescriptorFactory.defaultMarker(point.iconResource)) 54 | map.addMarker(markerOptions) 55 | } 56 | val bounds: LatLngBounds = builder.build() 57 | map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 120)) 58 | } 59 | } 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/splash/SplashScreen.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.splash 2 | 3 | import androidx.compose.foundation.Image 4 | import androidx.compose.foundation.layout.fillMaxSize 5 | import androidx.compose.foundation.layout.padding 6 | import androidx.compose.runtime.Composable 7 | import androidx.compose.runtime.collectAsState 8 | import androidx.compose.runtime.getValue 9 | import androidx.compose.ui.Modifier 10 | import androidx.compose.ui.layout.ContentScale 11 | import androidx.compose.ui.res.painterResource 12 | import androidx.hilt.navigation.compose.hiltViewModel 13 | import androidx.navigation.NavController 14 | import com.ekar.assignment.R 15 | import com.ekar.assignment.ui.Screen 16 | import com.ekar.assignment.ui.theme.padding_16 17 | 18 | /** 19 | * @author yusuf.onder 20 | * Created on 3.01.2022 21 | */ 22 | 23 | @Composable 24 | fun Splash(navController: NavController) { 25 | val viewModel = hiltViewModel() 26 | val event by viewModel.navigationEvent.collectAsState(SplashEvent.Initial) 27 | 28 | when (event) { 29 | is SplashEvent.Initial -> { 30 | Image( 31 | painter = painterResource(R.drawable.ekar_logo), 32 | contentDescription = "", 33 | contentScale = ContentScale.Fit, 34 | modifier = Modifier 35 | .fillMaxSize() 36 | .padding(padding_16) 37 | ) 38 | } 39 | is SplashEvent.NavigateToHome -> { 40 | navController.navigate(Screen.Map.route) 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/splash/SplashViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.splash 2 | 3 | import androidx.annotation.VisibleForTesting 4 | import androidx.lifecycle.viewModelScope 5 | import com.ekar.assignment.core.base.BaseViewModel 6 | import dagger.hilt.android.lifecycle.HiltViewModel 7 | import kotlinx.coroutines.delay 8 | import kotlinx.coroutines.flow.Flow 9 | import kotlinx.coroutines.flow.MutableSharedFlow 10 | import kotlinx.coroutines.launch 11 | import javax.inject.Inject 12 | 13 | /** 14 | * @author yusuf.onder 15 | * Created on 2.01.2022 16 | */ 17 | @HiltViewModel 18 | class SplashViewModel @Inject constructor(): BaseViewModel(){ 19 | 20 | private val _navigationEvent = MutableSharedFlow() 21 | val navigationEvent: Flow get() = _navigationEvent 22 | 23 | init { 24 | startSplash() 25 | } 26 | 27 | @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) 28 | internal fun startSplash() { 29 | viewModelScope.launch { 30 | delay(SPLASH_TIME_MILLIS) 31 | _navigationEvent.emit(SplashEvent.NavigateToHome) 32 | } 33 | } 34 | 35 | companion object { 36 | const val SPLASH_TIME_MILLIS = 2 * 1000L 37 | } 38 | } 39 | 40 | sealed class SplashEvent { 41 | object Initial : SplashEvent() 42 | object NavigateToHome : SplashEvent() 43 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.theme 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 3.01.2022 6 | */ 7 | import androidx.compose.ui.graphics.Color 8 | 9 | val Purple200 = Color(0xFFBB86FC) 10 | val Purple500 = Color(0xFF6200EE) 11 | val Purple700 = Color(0xFF3700B3) 12 | val Teal200 = Color(0xFF03DAC5) -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/theme/Padding.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.theme 2 | 3 | import androidx.compose.ui.unit.dp 4 | 5 | /** 6 | * @author yusuf.onder 7 | * Created on 2.01.2022 8 | */ 9 | 10 | val padding_4 = 4.dp 11 | val padding_8 = 8.dp 12 | val padding_12 = 12.dp 13 | val padding_16 = 16.dp 14 | val padding_24 = 24.dp 15 | val padding_32 = 32.dp -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/theme/Shapes.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.theme 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 3.01.2022 6 | */ 7 | import androidx.compose.foundation.shape.RoundedCornerShape 8 | import androidx.compose.material.Shapes 9 | import androidx.compose.ui.unit.dp 10 | 11 | val Shapes = Shapes( 12 | small = RoundedCornerShape(4.dp), 13 | medium = RoundedCornerShape(4.dp), 14 | large = RoundedCornerShape(0.dp) 15 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.theme 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 3.01.2022 6 | */ 7 | 8 | import androidx.compose.foundation.isSystemInDarkTheme 9 | import androidx.compose.material.MaterialTheme 10 | import androidx.compose.material.darkColors 11 | import androidx.compose.material.lightColors 12 | import androidx.compose.runtime.Composable 13 | 14 | private val DarkColorPalette = darkColors( 15 | primary = Purple200, 16 | primaryVariant = Purple700, 17 | secondary = Teal200 18 | ) 19 | 20 | private val LightColorPalette = lightColors( 21 | primary = Purple500, 22 | primaryVariant = Purple700, 23 | secondary = Teal200 24 | 25 | /* Other default colors to override 26 | background = Color.White, 27 | surface = Color.White, 28 | onPrimary = Color.White, 29 | onSecondary = Color.Black, 30 | onBackground = Color.Black, 31 | onSurface = Color.Black, 32 | */ 33 | ) 34 | 35 | @Composable 36 | fun EkarAssignmentTheme( 37 | darkTheme: Boolean = isSystemInDarkTheme(), 38 | content: @Composable() () -> Unit 39 | ) { 40 | val colors = if (darkTheme) { 41 | DarkColorPalette 42 | } else { 43 | LightColorPalette 44 | } 45 | 46 | MaterialTheme( 47 | colors = colors, 48 | typography = Typography, 49 | shapes = Shapes, 50 | content = content 51 | ) 52 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.theme 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 3.01.2022 6 | */ 7 | import androidx.compose.material.Typography 8 | import androidx.compose.ui.text.TextStyle 9 | import androidx.compose.ui.text.font.FontFamily 10 | import androidx.compose.ui.text.font.FontWeight 11 | import androidx.compose.ui.unit.sp 12 | 13 | // Set of Material typography styles to start with 14 | val Typography = Typography( 15 | body1 = TextStyle( 16 | fontFamily = FontFamily.Default, 17 | fontWeight = FontWeight.Normal, 18 | fontSize = 16.sp 19 | ) 20 | /* Other default text styles to override 21 | button = TextStyle( 22 | fontFamily = FontFamily.Default, 23 | fontWeight = FontWeight.W500, 24 | fontSize = 14.sp 25 | ), 26 | caption = TextStyle( 27 | fontFamily = FontFamily.Default, 28 | fontWeight = FontWeight.Normal, 29 | fontSize = 12.sp 30 | ) 31 | */ 32 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/vehicle/VehicleScreen.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.vehicle 2 | 3 | import android.widget.Toast 4 | import androidx.compose.foundation.Image 5 | import androidx.compose.foundation.background 6 | import androidx.compose.foundation.border 7 | import androidx.compose.foundation.layout.* 8 | import androidx.compose.foundation.lazy.LazyColumn 9 | import androidx.compose.foundation.shape.CircleShape 10 | import androidx.compose.material.CircularProgressIndicator 11 | import androidx.compose.material.ExperimentalMaterialApi 12 | import androidx.compose.material.MaterialTheme 13 | import androidx.compose.material.Text 14 | import androidx.compose.runtime.Composable 15 | import androidx.compose.runtime.collectAsState 16 | import androidx.compose.runtime.getValue 17 | import androidx.compose.ui.Alignment 18 | import androidx.compose.ui.Modifier 19 | import androidx.compose.ui.draw.clip 20 | import androidx.compose.ui.graphics.Color 21 | import androidx.compose.ui.layout.ContentScale 22 | import androidx.compose.ui.platform.LocalContext 23 | import androidx.compose.ui.res.colorResource 24 | import androidx.compose.ui.res.painterResource 25 | import androidx.compose.ui.res.stringResource 26 | import androidx.compose.ui.unit.dp 27 | import androidx.hilt.navigation.compose.hiltViewModel 28 | import androidx.navigation.NavController 29 | import com.ekar.assignment.R 30 | import com.ekar.assignment.ui.theme.padding_16 31 | import com.ekar.assignment.ui.theme.padding_4 32 | import com.ekar.assignment.ui.theme.padding_8 33 | import com.ekar.assignment.uicomponent.* 34 | 35 | /** 36 | * @author yusuf.onder 37 | * Created on 3.01.2022 38 | */ 39 | 40 | @ExperimentalMaterialApi 41 | @Composable 42 | fun VehicleScreen(navController: NavController) { 43 | val viewModel = hiltViewModel() 44 | val uiState by viewModel.uiState.collectAsState() 45 | val context = LocalContext.current 46 | 47 | if (uiState.isLoading) { 48 | LoadingView() 49 | } else { 50 | LazyColumn{ 51 | item { 52 | Box( 53 | modifier = Modifier 54 | .fillMaxWidth() 55 | .background(colorResource(id = R.color.ekar_blue_transparent)) 56 | ) { 57 | Column() { 58 | Image( 59 | painter = painterResource(R.drawable.ekar_car), 60 | contentDescription = stringResource(R.string.cd_car_image), 61 | contentScale = ContentScale.Crop, 62 | modifier = Modifier.fillMaxSize() 63 | ) 64 | 65 | Row( 66 | modifier = Modifier 67 | .fillMaxWidth() 68 | .padding(padding_8), 69 | horizontalArrangement = Arrangement.SpaceBetween 70 | ) { 71 | ShowcaseLabelType1( 72 | label = R.string.base_price, 73 | title = uiState.carDetail?.deliveryCharges.orEmpty(), 74 | subtitle = stringResource(id = R.string.aed_month) 75 | ) 76 | ShowcaseLabelType1( 77 | label = R.string.standard_seating, 78 | title = uiState.carDetail?.seat.orEmpty(), 79 | subtitle = stringResource(id = R.string.seating) 80 | ) 81 | } 82 | Row( 83 | modifier = Modifier 84 | .fillMaxWidth() 85 | .padding(padding_8), 86 | horizontalArrangement = Arrangement.SpaceBetween 87 | ) { 88 | ShowcaseLabelType2( 89 | label = R.string.booking_fee, 90 | title = uiState.carDetail?.bookingFee.orEmpty(), 91 | subtitle = uiState.carDetail?.currency.orEmpty(), 92 | ) 93 | 94 | ButtonType1(textResId = R.string.how_contracts_work) { 95 | Toast.makeText( 96 | context, 97 | R.string.message_button_actions, 98 | Toast.LENGTH_SHORT 99 | ).show() 100 | } 101 | 102 | } 103 | 104 | } 105 | } 106 | } 107 | 108 | if (uiState.carDetail?.year.isNullOrEmpty().not()) { 109 | item { 110 | Row( 111 | modifier = Modifier 112 | .fillMaxWidth() 113 | .padding(horizontal = padding_16), 114 | verticalAlignment = Alignment.CenterVertically, 115 | horizontalArrangement = Arrangement.Center 116 | ) { 117 | Text( 118 | text = uiState.carDetail?.formattedYear.orEmpty(), 119 | style = MaterialTheme.typography.h5, 120 | modifier = Modifier.padding(vertical = padding_8) 121 | ) 122 | } 123 | } 124 | } 125 | 126 | if (uiState.carDetail?.colors.isNullOrEmpty().not()) { 127 | item { 128 | Box(modifier = Modifier.padding(padding_8)) { 129 | Dropdown( 130 | labelResId = R.string.available_colors, 131 | options = uiState.carDetail?.colors.orEmpty() 132 | ) 133 | } 134 | 135 | } 136 | } 137 | item { 138 | Column( 139 | modifier = Modifier 140 | .padding(padding_16) 141 | ) { 142 | Row { 143 | Image( 144 | painter = painterResource(R.drawable.ekar_logo), 145 | contentDescription = stringResource(R.string.cd_car_image), 146 | contentScale = ContentScale.Crop, 147 | modifier = Modifier 148 | .size(64.dp) 149 | .clip(CircleShape) 150 | .border(1.dp, Color.LightGray, CircleShape) 151 | ) 152 | Column(modifier = Modifier.padding(horizontal = padding_8)) { 153 | Row { 154 | Text( 155 | text = uiState.carDetail?.make.orEmpty(), 156 | style = MaterialTheme.typography.h5, 157 | modifier = Modifier.padding(end = padding_4) 158 | ) 159 | Text( 160 | text = uiState.carDetail?.model.orEmpty(), 161 | style = MaterialTheme.typography.h5, 162 | color = Color.LightGray 163 | ) 164 | } 165 | Text( 166 | text = uiState.carDetail?.style.orEmpty(), 167 | style = MaterialTheme.typography.h6, 168 | color = Color.DarkGray 169 | ) 170 | } 171 | } 172 | 173 | ButtonType2(textResId = R.string.proceed_with_your_selection) { 174 | 175 | } 176 | 177 | } 178 | 179 | } 180 | } 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/ui/vehicle/VehicleViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.ui.vehicle 2 | 3 | import androidx.lifecycle.viewModelScope 4 | import com.ekar.assignment.core.base.BaseViewModel 5 | import com.ekar.assignment.data.model.request.CarDetailRequest 6 | import com.ekar.assignment.domain.uimodel.CarDetailUIModel 7 | import com.ekar.assignment.domain.usecase.GetCarDetail 8 | import dagger.hilt.android.lifecycle.HiltViewModel 9 | import kotlinx.coroutines.flow.MutableStateFlow 10 | import kotlinx.coroutines.flow.StateFlow 11 | import kotlinx.coroutines.flow.update 12 | import kotlinx.coroutines.launch 13 | import javax.inject.Inject 14 | 15 | /** 16 | * @author yusuf.onder 17 | * Created on 2.01.2022 18 | */ 19 | 20 | const val DEFAULT_KEY_VALUE = "tha91z6lv_j8u1nv4xs_ilfswb1e3" 21 | const val DEFAULT_VIN_VALUE = "JTDZN3EU0E3298500" 22 | 23 | @HiltViewModel 24 | class VehicleViewModel @Inject constructor(private val carDetail: GetCarDetail) : 25 | BaseViewModel() { 26 | 27 | private val _uiState = MutableStateFlow(UiState()) 28 | val uiState: StateFlow = _uiState 29 | 30 | init { 31 | getCarDetail() 32 | } 33 | 34 | private fun getCarDetail(key: String = DEFAULT_KEY_VALUE, vin: String = DEFAULT_VIN_VALUE) { 35 | viewModelScope.launch { 36 | _uiState.update { it.copy(isLoading = true) } 37 | request( 38 | flow = carDetail(CarDetailRequest(key = key, vin = vin)), 39 | onSuccess = { carDetail -> 40 | _uiState.update { it.copy(carDetail = carDetail, isLoading = false) } 41 | }) 42 | } 43 | } 44 | 45 | data class UiState( 46 | val isLoading: Boolean = true, 47 | val carDetail: CarDetailUIModel? = null 48 | ) 49 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/uicomponent/ButtonType1.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.uicomponent 2 | 3 | import androidx.annotation.ColorRes 4 | import androidx.annotation.StringRes 5 | import androidx.compose.foundation.BorderStroke 6 | import androidx.compose.foundation.shape.RoundedCornerShape 7 | import androidx.compose.material.ButtonDefaults 8 | import androidx.compose.material.OutlinedButton 9 | import androidx.compose.material.Text 10 | import androidx.compose.runtime.Composable 11 | import androidx.compose.ui.res.colorResource 12 | import androidx.compose.ui.res.stringResource 13 | import androidx.compose.ui.unit.dp 14 | import com.ekar.assignment.R 15 | 16 | /** 17 | * @author yusuf.onder 18 | * Created on 2.01.2022 19 | */ 20 | 21 | @Composable 22 | fun ButtonType1(@StringRes textResId: Int, @ColorRes color : Int = R.color.ekar_blue, onClick: () -> Unit) { 23 | OutlinedButton( 24 | onClick = onClick, 25 | border = BorderStroke(1.dp, colorResource(id = color)), 26 | shape = RoundedCornerShape(20), 27 | colors = ButtonDefaults.outlinedButtonColors(contentColor = colorResource(id = color)) 28 | ) { 29 | Text(text = stringResource(textResId)) 30 | } 31 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/uicomponent/ButtonType2.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.uicomponent 2 | 3 | import androidx.annotation.ColorRes 4 | import androidx.annotation.StringRes 5 | import androidx.compose.foundation.layout.fillMaxSize 6 | import androidx.compose.foundation.shape.RoundedCornerShape 7 | import androidx.compose.material.Button 8 | import androidx.compose.material.ButtonDefaults 9 | import androidx.compose.material.Text 10 | import androidx.compose.runtime.Composable 11 | import androidx.compose.ui.Modifier 12 | import androidx.compose.ui.graphics.Color 13 | import androidx.compose.ui.res.colorResource 14 | import androidx.compose.ui.res.stringResource 15 | import androidx.compose.ui.text.style.TextAlign 16 | import com.ekar.assignment.R 17 | 18 | /** 19 | * @author yusuf.onder 20 | * Created on 2.01.2022 21 | */ 22 | 23 | @Composable 24 | fun ButtonType2( 25 | @StringRes textResId: Int, 26 | @ColorRes color: Int = R.color.ekar_blue, 27 | onClick: () -> Unit 28 | ) { 29 | Button( 30 | onClick = onClick, 31 | shape = RoundedCornerShape(20), 32 | colors = ButtonDefaults.buttonColors( 33 | contentColor = Color.White, backgroundColor = colorResource( 34 | id = color 35 | ) 36 | ) 37 | ) { 38 | Text( 39 | text = stringResource(textResId), 40 | textAlign = TextAlign.Center, 41 | modifier = Modifier 42 | .fillMaxSize() 43 | ) 44 | } 45 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/uicomponent/Dropdown.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.uicomponent 2 | 3 | import androidx.annotation.StringRes 4 | import androidx.compose.foundation.background 5 | import androidx.compose.foundation.clickable 6 | import androidx.compose.foundation.layout.* 7 | import androidx.compose.material.* 8 | import androidx.compose.material.icons.Icons 9 | import androidx.compose.material.icons.filled.ArrowDropDown 10 | import androidx.compose.runtime.* 11 | import androidx.compose.ui.Alignment 12 | import androidx.compose.ui.Modifier 13 | import androidx.compose.ui.graphics.Color 14 | import androidx.compose.ui.res.stringResource 15 | import androidx.compose.ui.unit.dp 16 | import androidx.compose.ui.unit.sp 17 | import com.ekar.assignment.R 18 | import com.ekar.assignment.ui.theme.padding_16 19 | 20 | 21 | /** 22 | * @author yusuf.onder 23 | * Created on 2.01.2022 24 | */ 25 | 26 | 27 | @ExperimentalMaterialApi 28 | @Composable 29 | fun Dropdown(@StringRes labelResId : Int, options: List) { 30 | var expanded by remember { mutableStateOf(false) } 31 | var selectedOptionText by remember { mutableStateOf(options[0]) } 32 | 33 | ExposedDropdownMenuBox( 34 | expanded = expanded, 35 | onExpandedChange = { 36 | expanded = !expanded 37 | } 38 | ) { 39 | TextField( 40 | modifier = Modifier.fillMaxWidth(), 41 | readOnly = true, 42 | value = selectedOptionText, 43 | onValueChange = { }, 44 | label = { Text(stringResource(id = labelResId)) }, 45 | trailingIcon = { 46 | ExposedDropdownMenuDefaults.TrailingIcon( 47 | expanded = expanded 48 | ) 49 | }, 50 | colors = ExposedDropdownMenuDefaults.textFieldColors() 51 | ) 52 | ExposedDropdownMenu( 53 | expanded = expanded, 54 | onDismissRequest = { 55 | expanded = false 56 | } 57 | ) { 58 | options.forEach { selectionOption -> 59 | DropdownMenuItem( 60 | onClick = { 61 | selectedOptionText = selectionOption 62 | expanded = false 63 | } 64 | ) { 65 | Text(text = selectionOption) 66 | } 67 | } 68 | } 69 | 70 | } 71 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/uicomponent/LoadingView.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.uicomponent 2 | 3 | /** 4 | * @author yusuf.onder 5 | * Created on 3.01.2022 6 | */ 7 | 8 | import androidx.compose.foundation.layout.Box 9 | import androidx.compose.foundation.layout.Column 10 | import androidx.compose.foundation.layout.fillMaxSize 11 | import androidx.compose.foundation.layout.padding 12 | import androidx.compose.material.CircularProgressIndicator 13 | import androidx.compose.material.Text 14 | import androidx.compose.runtime.Composable 15 | import androidx.compose.ui.Alignment 16 | import androidx.compose.ui.Modifier 17 | import androidx.compose.ui.res.stringResource 18 | import androidx.compose.ui.tooling.preview.Preview 19 | import com.ekar.assignment.R 20 | import com.ekar.assignment.ui.theme.padding_8 21 | 22 | @Composable 23 | fun LoadingView(centerTextResId: Int = R.string.loading) { 24 | Box( 25 | modifier = Modifier 26 | .fillMaxSize(), 27 | contentAlignment = Alignment.Center 28 | ) { 29 | Column(horizontalAlignment = Alignment.CenterHorizontally) { 30 | CircularProgressIndicator( 31 | modifier = Modifier 32 | .padding(padding_8) 33 | ) 34 | Text(text = stringResource(id = centerTextResId)) 35 | } 36 | } 37 | } 38 | 39 | @Preview 40 | @Composable 41 | fun LoadingViewPreview() { 42 | LoadingView() 43 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/uicomponent/ShowCaseLabelType1.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.uicomponent 2 | 3 | import androidx.annotation.StringRes 4 | import androidx.compose.foundation.layout.Column 5 | import androidx.compose.foundation.layout.Row 6 | import androidx.compose.foundation.layout.padding 7 | import androidx.compose.material.MaterialTheme 8 | import androidx.compose.material.Text 9 | import androidx.compose.runtime.Composable 10 | import androidx.compose.ui.Alignment 11 | import androidx.compose.ui.Modifier 12 | import androidx.compose.ui.res.stringResource 13 | import com.ekar.assignment.ui.theme.padding_4 14 | 15 | /** 16 | * @author yusuf.onder 17 | * Created on 2.01.2022 18 | */ 19 | @Composable 20 | fun ShowcaseLabelType1(@StringRes label: Int, title: String, subtitle: String) { 21 | Column (){ 22 | Text( 23 | text = stringResource(id = label), 24 | style = MaterialTheme.typography.subtitle1, 25 | ) 26 | Row() { 27 | Text( 28 | text = title, 29 | style = MaterialTheme.typography.h5, 30 | modifier = Modifier.align(Alignment.Bottom).padding(end = padding_4) 31 | ) 32 | Text( 33 | text = subtitle, 34 | style = MaterialTheme.typography.subtitle2, 35 | modifier = Modifier.align(Alignment.Bottom) 36 | ) 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/uicomponent/ShowcaseLabelType2.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.uicomponent 2 | 3 | import androidx.annotation.StringRes 4 | import androidx.compose.foundation.layout.Column 5 | import androidx.compose.foundation.layout.Row 6 | import androidx.compose.foundation.layout.padding 7 | import androidx.compose.material.MaterialTheme 8 | import androidx.compose.material.Text 9 | import androidx.compose.runtime.Composable 10 | import androidx.compose.ui.Alignment 11 | import androidx.compose.ui.Modifier 12 | import androidx.compose.ui.res.stringResource 13 | import com.ekar.assignment.ui.theme.padding_4 14 | 15 | /** 16 | * @author yusuf.onder 17 | * Created on 2.01.2022 18 | */ 19 | @Composable 20 | fun ShowcaseLabelType2(@StringRes label: Int, title: String, subtitle: String) { 21 | Column { 22 | Text( 23 | text = stringResource(id = label), 24 | style = MaterialTheme.typography.subtitle1, 25 | ) 26 | Row { 27 | Text( 28 | text = subtitle, 29 | style = MaterialTheme.typography.subtitle2, 30 | modifier = Modifier.align(Alignment.Bottom).padding(end = padding_4) 31 | ) 32 | 33 | Text( 34 | text = title, 35 | style = MaterialTheme.typography.h5, 36 | modifier = Modifier 37 | .align(Alignment.Bottom) 38 | ) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/ekar/assignment/uicomponent/map/MapUtils.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment.uicomponent.map 2 | 3 | import android.os.Bundle 4 | import androidx.compose.runtime.Composable 5 | import androidx.compose.runtime.DisposableEffect 6 | import androidx.compose.runtime.remember 7 | import androidx.compose.ui.platform.LocalContext 8 | import androidx.compose.ui.platform.LocalLifecycleOwner 9 | import androidx.lifecycle.Lifecycle 10 | import androidx.lifecycle.LifecycleEventObserver 11 | import com.ekar.assignment.R 12 | import com.google.android.libraries.maps.MapView 13 | 14 | /** 15 | * @author yusuf.onder 16 | * Created on 1.01.2022 17 | */ 18 | @Composable 19 | fun rememberMapViewWithLifecycle(): MapView { 20 | val context = LocalContext.current 21 | val mapView = remember { 22 | MapView(context).apply { 23 | id = R.id.map 24 | } 25 | } 26 | 27 | // Makes MapView follow the lifecycle of this composable 28 | val lifecycleObserver = rememberMapLifecycleObserver(mapView) 29 | val lifecycle = LocalLifecycleOwner.current.lifecycle 30 | DisposableEffect(lifecycle) { 31 | lifecycle.addObserver(lifecycleObserver) 32 | onDispose { 33 | lifecycle.removeObserver(lifecycleObserver) 34 | } 35 | } 36 | 37 | return mapView 38 | } 39 | 40 | @Composable 41 | fun rememberMapLifecycleObserver(mapView: MapView): LifecycleEventObserver = 42 | remember(mapView) { 43 | LifecycleEventObserver { _, event -> 44 | when (event) { 45 | Lifecycle.Event.ON_CREATE -> mapView.onCreate(Bundle()) 46 | Lifecycle.Event.ON_START -> mapView.onStart() 47 | Lifecycle.Event.ON_RESUME -> mapView.onResume() 48 | Lifecycle.Event.ON_PAUSE -> mapView.onPause() 49 | Lifecycle.Event.ON_STOP -> mapView.onStop() 50 | Lifecycle.Event.ON_DESTROY -> mapView.onDestroy() 51 | else -> throw IllegalStateException() 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ekar_car.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/drawable-v24/ekar_car.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ekar_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/drawable-v24/ekar_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_map.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #FC44B7EA 11 | #6344B7EA 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8dp 4 | 16dp 5 | 16dp 6 | 8dp 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Ekar Assignment 3 | Proceed your selection 4 | Car Image 5 | Year 6 | Available colors 7 | Key features 8 | Base Price 9 | Contract Length 10 | Standard Seating 11 | AED/MONTH 12 | SEATING 13 | Booking Fee 14 | How contracts work? 15 | Toast messages 16 | Splash 17 | Vehicle 18 | Map 19 | Loading… 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/release/res/values/google_maps_api.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | YOUR_KEY_HERE 20 | -------------------------------------------------------------------------------- /app/src/test/java/com/ekar/assignment/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.ekar.assignment 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | 4 | repositories { 5 | google() 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath Libs.gradle 10 | classpath Libs.gradlePlugin 11 | classpath Libs.hiltPlugin 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | task clean(type: Delete) { 19 | delete rootProject.buildDir 20 | } -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins{ 2 | `kotlin-dsl` 3 | } 4 | repositories{ 5 | mavenCentral() 6 | } -------------------------------------------------------------------------------- /buildSrc/src/main/java/Config.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * @author yusuf.onder 3 | * Created on 3.01.2022 4 | */ 5 | object Config { 6 | const val applicationId = "com.ekar.assignment" 7 | const val versionCode = 1 8 | const val versionName = "1.0" 9 | const val compileSdkVersion = 31 10 | const val minSdkVersion = 21 11 | const val targetSdkVersion = 31 12 | const val buildToolsVersion = "30.0.3" 13 | const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 14 | const val proguard_txt = "proguard-android-optimize.txt" 15 | const val proguard_rules = "proguard-rules.pro" 16 | } -------------------------------------------------------------------------------- /buildSrc/src/main/java/Libs.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * @author yusuf.onder 3 | * Created on 3.01.2022 4 | */ 5 | 6 | object Libs { 7 | 8 | const val gradle: String = "com.android.tools.build:gradle:" + Versions.gradle 9 | const val gradlePlugin: String = "org.jetbrains.kotlin:kotlin-gradle-plugin:" + Versions.gradlePlugin 10 | 11 | //Network 12 | const val gson: String = "com.google.code.gson:gson:" + Versions.gson 13 | const val retrofit = "com.squareup.retrofit2:retrofit:" + Versions.retrofit 14 | const val converter = "com.squareup.retrofit2:converter-gson:" + Versions.retrofit 15 | const val okhttp = "com.squareup.okhttp3:okhttp:" + Versions.ok_http 16 | const val interceptor = "com.squareup.okhttp3:logging-interceptor:" + Versions.ok_http 17 | 18 | //Logging 19 | const val timber = "com.jakewharton.timber:timber:" + Versions.timber 20 | 21 | //Coroutines 22 | const val coroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:" + Versions.coroutines 23 | const val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:" + Versions.coroutines 24 | 25 | //Compose 26 | const val composeUi = "androidx.compose.ui:ui:" + Versions.compose 27 | const val composeMaterial = "androidx.compose.material:material:" + Versions.compose 28 | const val composeToolingPreview = "androidx.compose.ui:ui-tooling-preview:" + Versions.compose 29 | const val composeActivity = "androidx.activity:activity-compose:" + Versions.composeActivity 30 | const val composeNavigation = "androidx.navigation:navigation-compose:" + Versions.composeNavigation 31 | 32 | //Lifecycle AndroidX 33 | const val lifecycleViewModel = "androidx.lifecycle:lifecycle-viewmodel-ktx:" + Versions.lifecycle 34 | const val lifecycleRuntime = "androidx.lifecycle:lifecycle-runtime-ktx:" + Versions.lifecycle 35 | const val lifecycleLiveData = "androidx.lifecycle:lifecycle-livedata-ktx:" + Versions.lifecycle 36 | 37 | //Maps 38 | const val googleMaps = "com.google.android.libraries.maps:maps:" + Versions.googleMaps 39 | const val mapKtx = "com.google.maps.android:maps-v3-ktx:" + Versions.mapKtx 40 | 41 | //Fragment 42 | const val fragment = "androidx.fragment:fragment:" + Versions.fragment 43 | 44 | //Dagger Hilt 45 | const val hiltAndroid = "com.google.dagger:hilt-android:" + Versions.hilt 46 | const val hiltCompiler= "com.google.dagger:hilt-compiler:" + Versions.hilt 47 | const val hiltCompose = "androidx.hilt:hilt-navigation-compose:" + Versions.hiltCompose 48 | const val hiltPlugin = "com.google.dagger:hilt-android-gradle-plugin:" + Versions.hilt 49 | 50 | //AndroidX 51 | const val coreKtx = "androidx.core:core-ktx:" + Versions.coreKtx 52 | const val appCompat = "androidx.appcompat:appcompat:" + Versions.appCompat 53 | const val material = "com.google.android.material:material:" + Versions.appCompat 54 | 55 | //Test 56 | const val junit = "junit:junit:" + Versions.junit 57 | const val junitExt = "androidx.test.ext:junit:" + Versions.junitExt 58 | const val espresso = "androidx.test.espresso:espresso-core:" + Versions.espresso 59 | 60 | } -------------------------------------------------------------------------------- /buildSrc/src/main/java/Versions.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * @author yusuf.onder 3 | * Created on 3.01.2022 4 | */ 5 | 6 | object Versions { 7 | const val gradlePlugin: String = "1.5.31" 8 | const val gradle: String = "7.0.4" 9 | const val gson: String = "2.8.6" 10 | const val timber: String = "5.0.1" 11 | const val retrofit = "2.9.0" 12 | const val ok_http = "4.9.2" 13 | const val coroutines = "1.6.0" 14 | const val compose = "1.1.0-alpha06" 15 | const val composeNavigation = "2.4.0-rc01" 16 | const val composeActivity = "1.4.0" 17 | const val lifecycle = "2.4.0" 18 | const val googleMaps = "3.1.0-beta" 19 | const val mapKtx = "2.2.0" 20 | const val fragment = "1.4.0" 21 | const val hilt = "2.38.1" 22 | const val hiltCompose = "1.0.0-rc01" 23 | const val coreKtx = "1.7.0" 24 | const val appCompat = "1.4.0" 25 | const val espresso = "3.4.0" 26 | const val junit = "4.+" 27 | const val junitExt = "1.1.3" 28 | 29 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufonderd/EkarAssignment/dc8861da4a87f68f81d894689164f6e1092f2eb2/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 28 14:37:18 TRT 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 3 | repositories { 4 | google() 5 | mavenCentral() 6 | jcenter() // Warning: this repository is going to shut down soon 7 | } 8 | } 9 | rootProject.name = "Ekar Assignment" 10 | include ':app' 11 | --------------------------------------------------------------------------------