├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── gradle.xml └── misc.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ ├── HiltTestRunner.kt │ │ └── ibrajix │ │ ├── extension │ │ └── DiExtension.kt │ │ └── jetpacker │ │ └── ui │ │ └── fragments │ │ ├── FundWalletFragmentTest.kt │ │ └── HomeFragmentTest.kt │ ├── debug │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── ibrajix │ │ └── jetpacker │ │ └── HiltTestActivity.kt │ ├── main │ ├── AndroidManifest.xml │ ├── ic_logo-playstore.png │ ├── ic_main_logo-playstore.png │ ├── java │ │ └── com │ │ │ └── ibrajix │ │ │ └── jetpacker │ │ │ ├── di │ │ │ └── StorageModule.kt │ │ │ ├── global │ │ │ └── MyApplication.kt │ │ │ ├── storage │ │ │ ├── DataStorage.kt │ │ │ └── DataStorageImplementation.kt │ │ │ ├── ui │ │ │ ├── activities │ │ │ │ ├── ContainerActivity.kt │ │ │ │ └── MainActivity.kt │ │ │ ├── fragments │ │ │ │ ├── EnjoyRideFragment.kt │ │ │ │ ├── FundWalletFragment.kt │ │ │ │ ├── FundingSuccessFragment.kt │ │ │ │ ├── HomeFragment.kt │ │ │ │ ├── SelectDestination2Fragment.kt │ │ │ │ ├── SelectDestinationFragment.kt │ │ │ │ ├── SelectSpaceCraftFragment.kt │ │ │ │ └── TripDetailsFragment.kt │ │ │ ├── model │ │ │ │ └── TripDetails.kt │ │ │ └── viewmodel │ │ │ │ └── StorageViewModel.kt │ │ │ └── utils │ │ │ ├── Constants.kt │ │ │ ├── FragmentViewBindingDelegate.kt │ │ │ └── Utility.kt │ └── res │ │ ├── drawable │ │ ├── btn_solid_border.xml │ │ ├── et_round_border.xml │ │ ├── ic_back.xml │ │ ├── ic_empty_wallet.xml │ │ ├── ic_location.xml │ │ ├── ic_logo.xml │ │ ├── ic_main_logo_foreground.xml │ │ ├── ic_mark_green.xml │ │ ├── ic_rocket_falcon.xml │ │ ├── ic_start_journey.xml │ │ ├── lyt_with_border_and_stroke.xml │ │ ├── lyt_with_solid_border_grey.xml │ │ ├── lyt_with_solid_border_main_orange.xml │ │ └── lyt_with_solid_border_orange_opaque.xml │ │ ├── font │ │ ├── avenir_black.ttf │ │ └── avenir_regular.ttf │ │ ├── layout │ │ ├── activity_container.xml │ │ ├── activity_main.xml │ │ ├── fragment_enjoy_ride.xml │ │ ├── fragment_fund_wallet.xml │ │ ├── fragment_funding_success.xml │ │ ├── fragment_home.xml │ │ ├── fragment_select_destination.xml │ │ ├── fragment_select_destination2.xml │ │ ├── fragment_select_space_craft.xml │ │ └── fragment_trip_details.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_main_logo.xml │ │ └── ic_main_logo_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_main_logo.png │ │ └── ic_main_logo_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_main_logo.png │ │ └── ic_main_logo_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_main_logo.png │ │ └── ic_main_logo_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_main_logo.png │ │ └── ic_main_logo_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_main_logo.png │ │ └── ic_main_logo_round.png │ │ ├── navigation │ │ └── nav_graph.xml │ │ └── values │ │ ├── colors.xml │ │ ├── ic_logo_background.xml │ │ ├── ic_main_logo_background.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── ibrajix │ └── jetpacker │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

JetPacker

2 | 3 |

4 | License 5 | Medium 6 | Github Profile 7 | Twitter Profile 8 |

9 | 10 |

11 | JetPacker is an android application which implements various jetpack libraries created by the android team. 12 |

13 | 14 |
15 | 16 |

17 | 18 |

19 | 20 | ## FEATURES - (Will be updated as more jetpack lib. gets used) 21 | 22 | * Navigation Component 23 | * Hilt 24 | * DataBinding 25 | * DataStore 26 | * Custom View 27 | * Constraint Layout 28 | * Test (Espresso, Junit etc) 29 | * ViewModel 30 | 31 | ## EXTERNAL LIBRARIES USED 32 | * Animation - https://github.com/daimajia/AndroidViewAnimations 33 | * Confetti - https://github.com/DanielMartinus/Konfetti 34 | 35 |
36 | 37 | ![](https://media.giphy.com/media/BHvuvkkgM5BYgcwFzs/giphy.gif) 38 | 39 | 40 | ## DOWNLOAD 41 | Navigate to Releases and download the latest apk 42 | 43 | 44 | # License 45 | 46 | ```xml 47 | Designed and developed by 2021 Inuwa Ibrahim (ibrajix) 48 | 49 | Licensed under the Apache License, Version 2.0 (the "License"); 50 | you may not use this file except in compliance with the License. 51 | You may obtain a copy of the License at 52 | 53 | http://www.apache.org/licenses/LICENSE-2.0 54 | 55 | Unless required by applicable law or agreed to in writing, software 56 | distributed under the License is distributed on an "AS IS" BASIS, 57 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 58 | See the License for the specific language governing permissions and 59 | limitations under the License. 60 | ``` 61 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | //application 3 | id 'com.android.application' 4 | 5 | //android 6 | id 'kotlin-android' 7 | 8 | //safe args for passing data across fragments 9 | id 'androidx.navigation.safeargs.kotlin' 10 | 11 | //kotlin kapt - mainly for hilt 12 | id 'kotlin-kapt' 13 | 14 | //kotlin android extensions 15 | id 'kotlin-android-extensions' 16 | 17 | //dagger hilt for dependency injection 18 | id 'dagger.hilt.android.plugin' 19 | } 20 | 21 | android { 22 | compileSdk 30 23 | 24 | defaultConfig { 25 | applicationId "com.ibrajix.jetpacker" 26 | minSdk 21 27 | targetSdk 30 28 | versionCode 1 29 | versionName "1.0" 30 | 31 | testInstrumentationRunner "com.ibrajix.jetpacker.HiltTestRunner" 32 | } 33 | 34 | buildTypes { 35 | release { 36 | minifyEnabled false 37 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 38 | } 39 | } 40 | compileOptions { 41 | sourceCompatibility JavaVersion.VERSION_1_8 42 | targetCompatibility JavaVersion.VERSION_1_8 43 | } 44 | kotlinOptions { 45 | jvmTarget = '1.8' 46 | } 47 | buildFeatures { 48 | viewBinding true 49 | } 50 | } 51 | 52 | dependencies { 53 | 54 | //variables 55 | def hilt_android_version = "2.39.1" 56 | def lifecycle_version = "2.3.1" 57 | def nav_version = "2.3.5" 58 | def mockito_version = "3.9.0" 59 | 60 | //default - core 61 | implementation 'androidx.core:core-ktx:1.6.0' 62 | implementation 'androidx.appcompat:appcompat:1.3.1' 63 | implementation 'com.google.android.material:material:1.4.0' 64 | implementation 'androidx.constraintlayout:constraintlayout:2.1.1' 65 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 66 | 67 | //testing 68 | testImplementation 'junit:junit:4.13.2' 69 | testImplementation "com.google.truth:truth:1.1.3" 70 | 71 | 72 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 73 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 74 | androidTestImplementation "com.google.truth:truth:1.1.3" 75 | androidTestImplementation "com.google.dagger:hilt-android-testing:$hilt_android_version" 76 | kaptAndroidTest "com.google.dagger:hilt-android-compiler:$hilt_android_version" 77 | androidTestImplementation "androidx.navigation:navigation-testing:$nav_version" 78 | androidTestImplementation 'androidx.test:rules:1.4.0' 79 | 80 | //mockito 81 | androidTestImplementation "org.mockito:mockito-android:$mockito_version" 82 | 83 | def fragment_version = "1.3.6" 84 | debugImplementation "androidx.fragment:fragment-testing:$fragment_version" 85 | testImplementation "android.arch.core:core-testing:1.1.1" 86 | 87 | //animation 88 | implementation 'com.daimajia.androidanimations:library:2.4@aar' 89 | 90 | //lifeCycle 91 | implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" 92 | implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" 93 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" 94 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" 95 | 96 | //navigation component 97 | implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" 98 | implementation "androidx.navigation:navigation-ui-ktx:$nav_version" 99 | 100 | //transformation 101 | implementation "com.github.skydoves:transformationlayout:1.1.0" 102 | 103 | //data store 104 | implementation "androidx.datastore:datastore-preferences:1.0.0" 105 | 106 | //hilt - dependency injection 107 | implementation "com.google.dagger:hilt-android:$hilt_android_version" 108 | kapt "com.google.dagger:hilt-compiler:$hilt_android_version" 109 | 110 | //confetti 111 | implementation 'nl.dionsegijn:konfetti:1.3.2' 112 | 113 | //easing 114 | implementation 'com.daimajia.easing:library:2.4@aar' 115 | 116 | } -------------------------------------------------------------------------------- /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/HiltTestRunner.kt: -------------------------------------------------------------------------------- 1 | package com.ibrajix.jetpacker 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import androidx.test.runner.AndroidJUnitRunner 6 | import dagger.hilt.android.testing.HiltTestApplication 7 | 8 | class HiltTestRunner : AndroidJUnitRunner() { 9 | override fun newApplication(cl: ClassLoader?, name: String?, context: Context?): Application { 10 | return super.newApplication(cl, HiltTestApplication::class.java.name, context) 11 | } 12 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/ibrajix/extension/DiExtension.kt: -------------------------------------------------------------------------------- 1 | package com.ibrajix.extension 2 | 3 | import android.content.ComponentName 4 | import android.content.Intent 5 | import android.os.Bundle 6 | import androidx.annotation.StyleRes 7 | import androidx.core.util.Preconditions 8 | import androidx.fragment.app.Fragment 9 | import androidx.test.core.app.ActivityScenario 10 | import androidx.test.core.app.ApplicationProvider 11 | import com.ibrajix.jetpacker.HiltTestActivity 12 | import com.ibrajix.jetpacker.R 13 | 14 | inline fun launchFragmentInHiltContainer( 15 | fragmentArgs: Bundle? = null, 16 | @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, 17 | crossinline action: Fragment.() -> Unit = {} 18 | ) { 19 | val startActivityIntent = Intent.makeMainActivity( 20 | ComponentName( 21 | ApplicationProvider.getApplicationContext(), 22 | HiltTestActivity::class.java 23 | ) 24 | ).putExtra( 25 | "androidx.fragment.app.testing.FragmentScenario.EmptyFragmentActivity.THEME_EXTRAS_BUNDLE_KEY", 26 | themeResId 27 | ) 28 | 29 | ActivityScenario.launch(startActivityIntent).onActivity { activity -> 30 | val fragment: Fragment = activity.supportFragmentManager.fragmentFactory.instantiate( 31 | Preconditions.checkNotNull(T::class.java.classLoader), 32 | T::class.java.name 33 | ) 34 | fragment.arguments = fragmentArgs 35 | activity.supportFragmentManager 36 | .beginTransaction() 37 | .add(android.R.id.content, fragment, "") 38 | .commitNow() 39 | 40 | fragment.action() 41 | 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/ibrajix/jetpacker/ui/fragments/FundWalletFragmentTest.kt: -------------------------------------------------------------------------------- 1 | package com.ibrajix.jetpacker.ui.fragments 2 | 3 | import androidx.navigation.NavController 4 | import androidx.navigation.Navigation 5 | import androidx.test.espresso.Espresso 6 | import androidx.test.espresso.action.ViewActions 7 | import androidx.test.espresso.matcher.ViewMatchers 8 | import com.ibrajix.extension.launchFragmentInHiltContainer 9 | import com.ibrajix.jetpacker.R 10 | import dagger.hilt.android.testing.HiltAndroidRule 11 | import dagger.hilt.android.testing.HiltAndroidTest 12 | import junit.framework.TestCase 13 | import org.junit.Before 14 | import org.junit.Rule 15 | import org.junit.Test 16 | import org.mockito.Mockito 17 | 18 | @HiltAndroidTest 19 | class FundWalletFragmentTest{ 20 | 21 | @get:Rule(order = 0) 22 | var hiltAndroidRule = HiltAndroidRule(this) 23 | 24 | @Before 25 | fun setUp(){ 26 | hiltAndroidRule.inject() 27 | } 28 | 29 | @Test 30 | fun testThatOnClickBackButtonGoesBack(){ 31 | val navController = Mockito.mock(NavController::class.java) 32 | launchFragmentInHiltContainer{ 33 | Navigation.setViewNavController(requireView(), navController) 34 | } 35 | Espresso.onView(ViewMatchers.withId(R.id.ic_back)).perform(ViewActions.click()) 36 | Mockito.verify(navController).popBackStack() 37 | } 38 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/ibrajix/jetpacker/ui/fragments/HomeFragmentTest.kt: -------------------------------------------------------------------------------- 1 | package com.ibrajix.jetpacker.ui.fragments 2 | 3 | import androidx.navigation.NavController 4 | import androidx.navigation.Navigation 5 | import androidx.test.espresso.Espresso.onView 6 | import androidx.test.espresso.action.ViewActions.click 7 | import androidx.test.espresso.matcher.ViewMatchers.withId 8 | import com.ibrajix.extension.launchFragmentInHiltContainer 9 | import com.ibrajix.jetpacker.R 10 | import dagger.hilt.android.testing.HiltAndroidRule 11 | import dagger.hilt.android.testing.HiltAndroidTest 12 | import org.junit.Before 13 | import org.junit.Rule 14 | import org.junit.Test 15 | import org.mockito.Mockito.mock 16 | import org.mockito.Mockito.verify 17 | 18 | 19 | @HiltAndroidTest 20 | class HomeFragmentTest{ 21 | 22 | @get:Rule(order = 0) 23 | var hiltAndroidRule = HiltAndroidRule(this) 24 | 25 | @Before 26 | fun setUp(){ 27 | hiltAndroidRule.inject() 28 | } 29 | 30 | @Test 31 | fun testThatOnClickFundWalletButtonNavigateToFundWalletFragment(){ 32 | val navController = mock(NavController::class.java) 33 | launchFragmentInHiltContainer{ 34 | Navigation.setViewNavController(requireView(), navController) 35 | } 36 | onView(withId(R.id.btn_fund_wallet)).perform(click()) 37 | verify(navController).navigate(HomeFragmentDirections.actionHomeFragmentToFundWalletFragment()) 38 | } 39 | 40 | @Test 41 | fun testThatOnClickStartYourJourneyNavigateToSelectSpaceCraftFragment(){ 42 | val navController = mock(NavController::class.java) 43 | launchFragmentInHiltContainer { 44 | Navigation.setViewNavController(requireView(), navController) 45 | } 46 | onView(withId(R.id.lyt_start_journey)).perform(click()) 47 | verify(navController).navigate(HomeFragmentDirections.actionHomeFragmentToSelectSpaceCraftFragment()) 48 | } 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/debug/java/com/ibrajix/jetpacker/HiltTestActivity.kt: -------------------------------------------------------------------------------- 1 | package com.ibrajix.jetpacker 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import dagger.hilt.android.AndroidEntryPoint 5 | 6 | @AndroidEntryPoint 7 | class HiltTestActivity : AppCompatActivity() -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/ic_logo-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibrajix/JetPacker/f4e01e506acb3d0fcae66c05e877b45e5216d405/app/src/main/ic_logo-playstore.png -------------------------------------------------------------------------------- /app/src/main/ic_main_logo-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibrajix/JetPacker/f4e01e506acb3d0fcae66c05e877b45e5216d405/app/src/main/ic_main_logo-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/di/StorageModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.di 6 | 7 | import com.ibrajix.jetpacker.storage.DataStorage 8 | import com.ibrajix.jetpacker.storage.DataStorageImplementation 9 | import dagger.Binds 10 | import dagger.Module 11 | import dagger.hilt.InstallIn 12 | import dagger.hilt.components.SingletonComponent 13 | 14 | @Module 15 | @InstallIn(SingletonComponent::class) 16 | abstract class StorageModule { 17 | 18 | @Binds 19 | abstract fun bindDataStorage(dataStorageImplementation: DataStorageImplementation): DataStorage 20 | 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/global/MyApplication.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.global 6 | 7 | import android.app.Application 8 | import dagger.hilt.android.HiltAndroidApp 9 | 10 | @HiltAndroidApp 11 | class MyApplication : Application() -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/storage/DataStorage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.storage 6 | 7 | import kotlinx.coroutines.flow.Flow 8 | 9 | interface DataStorage { 10 | 11 | fun getWalletBalance() : Flow 12 | suspend fun setWalletBalance(balance: String) 13 | 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/storage/DataStorageImplementation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.storage 6 | 7 | import android.content.Context 8 | import androidx.datastore.core.DataStore 9 | import androidx.datastore.preferences.core.Preferences 10 | import androidx.datastore.preferences.core.edit 11 | import androidx.datastore.preferences.core.emptyPreferences 12 | import androidx.datastore.preferences.core.stringPreferencesKey 13 | import androidx.datastore.preferences.preferencesDataStore 14 | import dagger.hilt.android.qualifiers.ApplicationContext 15 | import kotlinx.coroutines.flow.catch 16 | import kotlinx.coroutines.flow.map 17 | import java.io.IOException 18 | import javax.inject.Inject 19 | import javax.inject.Singleton 20 | 21 | val Context.dataStore: DataStore by preferencesDataStore(name = "data_Storage") 22 | 23 | @Singleton 24 | class DataStorageImplementation @Inject constructor(@ApplicationContext context: Context) : DataStorage { 25 | 26 | private val dataStore = context.dataStore 27 | 28 | //keys 29 | private object PreferenceKeys{ 30 | val WALLET_BALANCE = stringPreferencesKey("wallet_ballance") 31 | } 32 | 33 | override fun getWalletBalance() = dataStore.data.catch { 34 | if (it is IOException){ 35 | emit(emptyPreferences()) 36 | } else { 37 | throw it 38 | } 39 | }.map { 40 | it[PreferenceKeys.WALLET_BALANCE] ?: "0.0000" 41 | } 42 | 43 | override suspend fun setWalletBalance(balance: String) { 44 | dataStore.edit { 45 | it[PreferenceKeys.WALLET_BALANCE] = balance 46 | } 47 | } 48 | 49 | 50 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/activities/ContainerActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.activities 6 | 7 | import android.os.Bundle 8 | import androidx.appcompat.app.AppCompatActivity 9 | import com.ibrajix.jetpacker.R 10 | import com.ibrajix.jetpacker.utils.Utility.whiteStatusBar 11 | import dagger.hilt.android.AndroidEntryPoint 12 | 13 | /** 14 | * This activity hosts the entire fragments 15 | */ 16 | 17 | @AndroidEntryPoint 18 | class ContainerActivity : AppCompatActivity() { 19 | override fun onCreate(savedInstanceState: Bundle?) { 20 | super.onCreate(savedInstanceState) 21 | whiteStatusBar() 22 | setContentView(R.layout.activity_container) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/activities/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.activities 6 | 7 | import android.content.Intent 8 | import android.os.Bundle 9 | import android.os.Handler 10 | import android.os.Looper 11 | import androidx.appcompat.app.AppCompatActivity 12 | import com.daimajia.androidanimations.library.Techniques 13 | import com.daimajia.androidanimations.library.YoYo 14 | import com.ibrajix.jetpacker.databinding.ActivityMainBinding 15 | import com.ibrajix.jetpacker.utils.Constants.SPLASH_SCREEN_TIME 16 | import com.ibrajix.jetpacker.utils.Utility.whiteStatusBar 17 | import dagger.hilt.android.AndroidEntryPoint 18 | 19 | /** 20 | * This is the launcher activity which displays on first time visit 21 | */ 22 | 23 | 24 | @AndroidEntryPoint 25 | class MainActivity : AppCompatActivity() { 26 | 27 | private lateinit var binding: ActivityMainBinding 28 | 29 | override fun onCreate(savedInstanceState: Bundle?) { 30 | super.onCreate(savedInstanceState) 31 | 32 | whiteStatusBar() 33 | binding = ActivityMainBinding.inflate(layoutInflater) 34 | setContentView(binding.root) 35 | 36 | //initialize view 37 | initView() 38 | 39 | } 40 | 41 | private fun initView(){ 42 | startAnimation() 43 | goToNextActivity() 44 | } 45 | 46 | private fun startAnimation(){ 47 | 48 | YoYo.with(Techniques.RotateInDownLeft) 49 | .duration(3000) 50 | .repeat(0) 51 | .playOn(binding.icLogo) 52 | 53 | YoYo.with(Techniques.RotateInDownRight) 54 | .duration(3000) 55 | .repeat(0) 56 | .playOn(binding.txtSpacex) 57 | 58 | YoYo.with(Techniques.RotateInDownRight) 59 | .duration(3000) 60 | .repeat(0) 61 | .playOn(binding.txtOdyssey) 62 | 63 | } 64 | 65 | /** 66 | * Normally, I don't use this splash screen implementation approach, I only use this to showcase the startup animation 67 | */ 68 | 69 | private fun goToNextActivity(){ 70 | 71 | //delay for 5 seconds and move to next activity 72 | Handler(Looper.getMainLooper()).postDelayed({ 73 | val intent = Intent(this, ContainerActivity::class.java) 74 | startActivity(intent) 75 | finish()}, SPLASH_SCREEN_TIME) 76 | 77 | } 78 | 79 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/fragments/EnjoyRideFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.fragments 6 | 7 | import android.graphics.Color 8 | import android.os.Bundle 9 | import android.view.LayoutInflater 10 | import android.view.View 11 | import android.view.ViewGroup 12 | import androidx.fragment.app.Fragment 13 | import com.daimajia.androidanimations.library.Techniques 14 | import com.daimajia.androidanimations.library.YoYo 15 | import com.ibrajix.jetpacker.R 16 | import com.ibrajix.jetpacker.databinding.FragmentEnjoyRideBinding 17 | import com.ibrajix.jetpacker.utils.viewBinding 18 | import nl.dionsegijn.konfetti.models.Shape 19 | import nl.dionsegijn.konfetti.models.Size 20 | 21 | class EnjoyRideFragment : Fragment() { 22 | 23 | private val binding by viewBinding(FragmentEnjoyRideBinding::bind) 24 | 25 | override fun onCreate(savedInstanceState: Bundle?) { 26 | super.onCreate(savedInstanceState) 27 | } 28 | 29 | override fun onCreateView( 30 | inflater: LayoutInflater, container: ViewGroup?, 31 | savedInstanceState: Bundle? 32 | ): View? { 33 | // Inflate the layout for this fragment 34 | return inflater.inflate(R.layout.fragment_enjoy_ride, container, false) 35 | } 36 | 37 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 38 | super.onViewCreated(view, savedInstanceState) 39 | initView() 40 | } 41 | 42 | private fun initView(){ 43 | 44 | /** 45 | * Do some animation and cofetti view with the aid of third party libraries 46 | */ 47 | 48 | 49 | YoYo.with(Techniques.Swing) 50 | .duration(3000) 51 | .repeat(3) 52 | .playOn(binding.icLogo) 53 | 54 | binding.viewKonfetti.build() 55 | .addColors(Color.YELLOW, Color.GREEN, Color.MAGENTA) 56 | .setDirection(0.0, 359.0) 57 | .setSpeed(1f, 5f) 58 | .setFadeOutEnabled(true) 59 | .setTimeToLive(5000L) 60 | .addShapes(Shape.Square, Shape.Circle) 61 | .addSizes(Size(12)) 62 | .setPosition(-50f, binding.viewKonfetti.width + 50f, -50f, -50f) 63 | .streamFor(300, 5000L) 64 | 65 | } 66 | 67 | 68 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/fragments/FundWalletFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.fragments 6 | 7 | import android.os.Bundle 8 | import android.view.LayoutInflater 9 | import android.view.View 10 | import android.view.ViewGroup 11 | import androidx.fragment.app.Fragment 12 | import androidx.fragment.app.viewModels 13 | import androidx.navigation.fragment.findNavController 14 | import com.ibrajix.jetpacker.R 15 | import com.ibrajix.jetpacker.databinding.FragmentFundWalletBinding 16 | import com.ibrajix.jetpacker.ui.viewmodel.StorageViewModel 17 | import com.ibrajix.jetpacker.utils.viewBinding 18 | import dagger.hilt.android.AndroidEntryPoint 19 | 20 | 21 | @AndroidEntryPoint 22 | class FundWalletFragment : Fragment() { 23 | 24 | private val viewModel: StorageViewModel by viewModels() 25 | 26 | private val binding by viewBinding(FragmentFundWalletBinding::bind) 27 | 28 | override fun onCreate(savedInstanceState: Bundle?) { 29 | super.onCreate(savedInstanceState) 30 | 31 | } 32 | 33 | override fun onCreateView( 34 | inflater: LayoutInflater, container: ViewGroup?, 35 | savedInstanceState: Bundle? 36 | ): View? { 37 | // Inflate the layout for this fragment 38 | return inflater.inflate(R.layout.fragment_fund_wallet, container, false) 39 | } 40 | 41 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 42 | super.onViewCreated(view, savedInstanceState) 43 | initView() 44 | } 45 | 46 | private fun initView(){ 47 | handleClicks() 48 | } 49 | 50 | private fun handleClicks(){ 51 | 52 | //on click back 53 | binding.icBack.setOnClickListener { 54 | findNavController().popBackStack() 55 | } 56 | 57 | //on click button fund wallet 58 | binding.btnFundWallet.setOnClickListener { 59 | 60 | //set balance 61 | viewModel.changeWalletBalance(binding.editText.text.toString()) 62 | 63 | //navigate to success screen 64 | findNavController().navigate(FundWalletFragmentDirections.actionFundWalletFragmentToFundingSuccessFragment()) 65 | } 66 | 67 | } 68 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/fragments/FundingSuccessFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.fragments 6 | 7 | import android.os.Bundle 8 | import android.view.LayoutInflater 9 | import android.view.View 10 | import android.view.ViewGroup 11 | import androidx.fragment.app.Fragment 12 | import androidx.navigation.fragment.findNavController 13 | import com.ibrajix.jetpacker.R 14 | import com.ibrajix.jetpacker.databinding.FragmentFundingSuccessBinding 15 | import com.ibrajix.jetpacker.utils.viewBinding 16 | 17 | class FundingSuccessFragment : Fragment() { 18 | 19 | private val binding by viewBinding(FragmentFundingSuccessBinding::bind) 20 | 21 | override fun onCreate(savedInstanceState: Bundle?) { 22 | super.onCreate(savedInstanceState) 23 | } 24 | 25 | override fun onCreateView( 26 | inflater: LayoutInflater, container: ViewGroup?, 27 | savedInstanceState: Bundle? 28 | ): View? { 29 | // Inflate the layout for this fragment 30 | return inflater.inflate(R.layout.fragment_funding_success, container, false) 31 | } 32 | 33 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 34 | super.onViewCreated(view, savedInstanceState) 35 | initView() 36 | } 37 | 38 | private fun initView(){ 39 | handleClick() 40 | } 41 | 42 | private fun handleClick(){ 43 | 44 | //on click back 45 | binding.btnOkay.setOnClickListener { 46 | findNavController().navigate(FundingSuccessFragmentDirections.actionFundingSuccessFragmentToHomeFragment()) 47 | } 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/fragments/HomeFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.fragments 6 | 7 | import android.os.Bundle 8 | import androidx.fragment.app.Fragment 9 | import android.view.LayoutInflater 10 | import android.view.View 11 | import android.view.ViewGroup 12 | import androidx.fragment.app.viewModels 13 | import androidx.navigation.fragment.findNavController 14 | import com.ibrajix.jetpacker.R 15 | import com.ibrajix.jetpacker.databinding.FragmentHomeBinding 16 | import com.ibrajix.jetpacker.ui.viewmodel.StorageViewModel 17 | import com.ibrajix.jetpacker.utils.viewBinding 18 | import dagger.hilt.android.AndroidEntryPoint 19 | 20 | @AndroidEntryPoint 21 | class HomeFragment : Fragment() { 22 | 23 | private val binding by viewBinding(FragmentHomeBinding::bind) 24 | private val viewModel: StorageViewModel by viewModels() 25 | private var walletBalance: String? = null 26 | 27 | override fun onCreate(savedInstanceState: Bundle?) { 28 | super.onCreate(savedInstanceState) 29 | } 30 | 31 | override fun onCreateView( 32 | inflater: LayoutInflater, container: ViewGroup?, 33 | savedInstanceState: Bundle? 34 | ): View? { 35 | // Inflate the layout for this fragment 36 | return inflater.inflate(R.layout.fragment_home, container, false) 37 | } 38 | 39 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 40 | super.onViewCreated(view, savedInstanceState) 41 | initView() 42 | } 43 | 44 | private fun initView(){ 45 | observe() 46 | handleClicks() 47 | } 48 | 49 | /** 50 | * Observe changes to wallet balance - livedata 51 | */ 52 | 53 | private fun observe(){ 54 | 55 | viewModel.walletBalance.observe(viewLifecycleOwner){ 56 | walletBalance = it 57 | binding.txtBtcAmount.text = walletBalance 58 | } 59 | 60 | } 61 | 62 | 63 | private fun handleClicks(){ 64 | 65 | //on click btn fund wallet 66 | binding.btnFundWallet.setOnClickListener { 67 | findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToFundWalletFragment()) 68 | } 69 | 70 | //on click start journey 71 | binding.lytStartJourney.setOnClickListener { 72 | findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToSelectSpaceCraftFragment()) 73 | } 74 | 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/fragments/SelectDestination2Fragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.fragments 6 | 7 | import android.os.Bundle 8 | import android.view.LayoutInflater 9 | import android.view.View 10 | import android.view.ViewGroup 11 | import androidx.fragment.app.Fragment 12 | import androidx.navigation.fragment.findNavController 13 | import com.ibrajix.jetpacker.R 14 | import com.ibrajix.jetpacker.databinding.FragmentSelectDestination2Binding 15 | import com.ibrajix.jetpacker.ui.model.TripDetails 16 | import com.ibrajix.jetpacker.utils.viewBinding 17 | 18 | class SelectDestination2Fragment : Fragment() { 19 | 20 | private val binding by viewBinding(FragmentSelectDestination2Binding::bind) 21 | 22 | override fun onCreate(savedInstanceState: Bundle?) { 23 | super.onCreate(savedInstanceState) 24 | } 25 | 26 | override fun onCreateView( 27 | inflater: LayoutInflater, container: ViewGroup?, 28 | savedInstanceState: Bundle? 29 | ): View? { 30 | // Inflate the layout for this fragment 31 | return inflater.inflate(R.layout.fragment_select_destination2, container, false) 32 | } 33 | 34 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 35 | super.onViewCreated(view, savedInstanceState) 36 | initView() 37 | } 38 | 39 | private fun initView(){ 40 | 41 | //handle clicks 42 | handleClicks() 43 | } 44 | 45 | private fun handleClicks(){ 46 | 47 | 48 | //on click back 49 | binding.icBack.setOnClickListener { 50 | findNavController().popBackStack() 51 | } 52 | 53 | val tripDetails1 = TripDetails( 54 | spaceCraft = requireContext().getString(R.string.falcon_9), 55 | station = requireContext().getString(R.string.abuja_to_moon), 56 | orbit = requireContext().getString(R.string.earth_earth), 57 | type = requireContext().getString(R.string.natural), 58 | fair_2 = requireContext().getString(R.string.royalty_landing), 59 | btc_2 = requireContext().getString(R.string.two_hundred_btc), 60 | ) 61 | 62 | val tripDetails2 = TripDetails( 63 | spaceCraft = requireContext().getString(R.string.falcon_9), 64 | station = requireContext().getString(R.string.mars_to_space), 65 | orbit = requireContext().getString(R.string.mars_earth), 66 | type = requireContext().getString(R.string.manmade), 67 | fair_2 = requireContext().getString(R.string.royalty_landing), 68 | btc_2 = requireContext().getString(R.string.two_hundred_btc), 69 | ) 70 | 71 | //on click destination 72 | binding.lytAbujaToMoon.setOnClickListener { 73 | findNavController().navigate(SelectDestination2FragmentDirections.actionSelectDestination2FragmentToTripDetailsFragment(tripDetails = tripDetails1)) 74 | } 75 | 76 | //on click destination 77 | binding.lytMarsToInternationalSpace.setOnClickListener { 78 | findNavController().navigate(SelectDestination2FragmentDirections.actionSelectDestination2FragmentToTripDetailsFragment(tripDetails2)) 79 | } 80 | 81 | } 82 | 83 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/fragments/SelectDestinationFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.fragments 6 | 7 | import android.os.Bundle 8 | import android.view.LayoutInflater 9 | import android.view.View 10 | import android.view.ViewGroup 11 | import androidx.fragment.app.Fragment 12 | import androidx.navigation.fragment.findNavController 13 | import com.ibrajix.jetpacker.R 14 | import com.ibrajix.jetpacker.databinding.FragmentSelectDestinationBinding 15 | import com.ibrajix.jetpacker.ui.model.TripDetails 16 | import com.ibrajix.jetpacker.utils.viewBinding 17 | 18 | class SelectDestinationFragment : Fragment() { 19 | 20 | private val binding by viewBinding(FragmentSelectDestinationBinding::bind) 21 | 22 | override fun onCreate(savedInstanceState: Bundle?) { 23 | super.onCreate(savedInstanceState) 24 | 25 | } 26 | 27 | override fun onCreateView( 28 | inflater: LayoutInflater, container: ViewGroup?, 29 | savedInstanceState: Bundle? 30 | ): View? { 31 | // Inflate the layout for this fragment 32 | return inflater.inflate(R.layout.fragment_select_destination, container, false) 33 | } 34 | 35 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 36 | super.onViewCreated(view, savedInstanceState) 37 | initView() 38 | } 39 | 40 | private fun initView(){ 41 | handleClicks() 42 | } 43 | 44 | private fun handleClicks(){ 45 | 46 | val tripDetails = TripDetails( 47 | spaceCraft = requireContext().getString(R.string.falcon_1), 48 | station = requireContext().getString(R.string.moon_to_spook_stations), 49 | orbit = requireContext().getString(R.string.earth_mass), 50 | type = requireContext().getString(R.string.natural), 51 | fair_1 = requireContext().getString(R.string.cross_orbit), 52 | fair_2 = requireContext().getString(R.string.royalty_landing), 53 | fair_3 = requireContext().getString(R.string.journey_2_points), 54 | btc_1 = requireContext().getString(R.string.two_fifty_btc), 55 | btc_2 = requireContext().getString(R.string.two_hundred_btc), 56 | btc_3 = requireContext().getString(R.string.fifty_btc), 57 | ) 58 | 59 | //on click back 60 | binding.icBack.setOnClickListener { 61 | findNavController().popBackStack() 62 | } 63 | 64 | //on click destination 65 | binding.lytFalcon1.setOnClickListener { 66 | findNavController().navigate(SelectDestinationFragmentDirections.actionSelectDestinationFragmentToTripDetailsFragment(tripDetails = tripDetails)) 67 | } 68 | 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/fragments/SelectSpaceCraftFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.fragments 6 | 7 | import android.os.Bundle 8 | import androidx.fragment.app.Fragment 9 | import android.view.LayoutInflater 10 | import android.view.View 11 | import android.view.ViewGroup 12 | import android.widget.Toast 13 | import androidx.fragment.app.viewModels 14 | import androidx.navigation.fragment.findNavController 15 | import com.ibrajix.jetpacker.R 16 | import com.ibrajix.jetpacker.databinding.FragmentSelectSpaceCraftBinding 17 | import com.ibrajix.jetpacker.ui.viewmodel.StorageViewModel 18 | import com.ibrajix.jetpacker.utils.viewBinding 19 | import dagger.hilt.android.AndroidEntryPoint 20 | 21 | 22 | @AndroidEntryPoint 23 | class SelectSpaceCraftFragment : Fragment() { 24 | 25 | private val binding by viewBinding(FragmentSelectSpaceCraftBinding::bind) 26 | private val viewModel: StorageViewModel by viewModels() 27 | 28 | override fun onCreate(savedInstanceState: Bundle?) { 29 | super.onCreate(savedInstanceState) 30 | } 31 | 32 | override fun onCreateView( 33 | inflater: LayoutInflater, container: ViewGroup?, 34 | savedInstanceState: Bundle? 35 | ): View? { 36 | // Inflate the layout for this fragment 37 | return inflater.inflate(R.layout.fragment_select_space_craft, container, false) 38 | } 39 | 40 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 41 | super.onViewCreated(view, savedInstanceState) 42 | initView() 43 | } 44 | 45 | private fun initView(){ 46 | observe() 47 | handleClicks() 48 | } 49 | 50 | private fun observe(){ 51 | viewModel.walletBalance.observe(viewLifecycleOwner){ 52 | 53 | //check if saved value in data store is equal to the default 54 | if (!it.equals(requireContext().getString(R.string.zero_btc))){ 55 | binding.lytWalletFunded.visibility = View.VISIBLE 56 | binding.lytNoFunds.visibility = View.GONE 57 | } 58 | 59 | else{ 60 | binding.lytWalletFunded.visibility = View.GONE 61 | binding.lytNoFunds.visibility = View.VISIBLE 62 | } 63 | 64 | } 65 | } 66 | 67 | private fun handleClicks(){ 68 | 69 | //on click back 70 | binding.icBack.setOnClickListener { 71 | findNavController().popBackStack() 72 | } 73 | 74 | 75 | //on click falcon 1 76 | binding.lytFalcon1.setOnClickListener { 77 | findNavController().navigate(SelectSpaceCraftFragmentDirections.actionSelectSpaceCraftFragmentToSelectDestinationFragment()) 78 | } 79 | 80 | //on click falcon 9 81 | binding.lytFalcon9.setOnClickListener { 82 | findNavController().navigate(SelectSpaceCraftFragmentDirections.actionSelectSpaceCraftFragmentToSelectDestination2Fragment()) 83 | } 84 | 85 | //on click btn fund 86 | binding.btnFundWallet.setOnClickListener { 87 | findNavController().navigate(SelectSpaceCraftFragmentDirections.actionSelectSpaceCraftFragmentToFundWalletFragment()) 88 | } 89 | 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/fragments/TripDetailsFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.fragments 6 | 7 | import android.os.Bundle 8 | import android.view.LayoutInflater 9 | import android.view.View 10 | import android.view.ViewGroup 11 | import androidx.fragment.app.Fragment 12 | import androidx.navigation.fragment.findNavController 13 | import androidx.navigation.fragment.navArgs 14 | import com.ibrajix.jetpacker.R 15 | import com.ibrajix.jetpacker.databinding.FragmentTripDetailsBinding 16 | import com.ibrajix.jetpacker.utils.viewBinding 17 | 18 | class TripDetailsFragment : Fragment() { 19 | 20 | private val binding by viewBinding(FragmentTripDetailsBinding::bind) 21 | private val args: TripDetailsFragmentArgs by navArgs() 22 | 23 | override fun onCreate(savedInstanceState: Bundle?) { 24 | super.onCreate(savedInstanceState) 25 | 26 | } 27 | 28 | override fun onCreateView( 29 | inflater: LayoutInflater, container: ViewGroup?, 30 | savedInstanceState: Bundle? 31 | ): View? { 32 | // Inflate the layout for this fragment 33 | return inflater.inflate(R.layout.fragment_trip_details, container, false) 34 | } 35 | 36 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 37 | super.onViewCreated(view, savedInstanceState) 38 | initView() 39 | } 40 | 41 | private fun initView(){ 42 | 43 | setView() 44 | 45 | handleClicks() 46 | } 47 | 48 | private fun setView(){ 49 | 50 | binding.txtBtc1.text = args.tripDetails.btc_1 51 | binding.txtBtc2.text = args.tripDetails.btc_2 52 | binding.txtBtc3.text = args.tripDetails.btc_3 53 | binding.txtFair1.text = args.tripDetails.fair_1 54 | binding.txtFair2.text = args.tripDetails.fair_2 55 | binding.txtFair3.text = args.tripDetails.fair_3 56 | binding.txtOrbit.text = args.tripDetails.orbit 57 | binding.txtSpaceCraft.text = args.tripDetails.spaceCraft 58 | binding.txtStation.text = args.tripDetails.station 59 | binding.txtType.text = args.tripDetails.type 60 | 61 | } 62 | 63 | private fun handleClicks(){ 64 | 65 | //on click back 66 | binding.icBack.setOnClickListener { 67 | findNavController().popBackStack() 68 | } 69 | 70 | //on click begin trip 71 | binding.btnBeginTrip.setOnClickListener { 72 | findNavController().navigate(TripDetailsFragmentDirections.actionTripDetailsFragmentToEnjoyRideFragment()) 73 | } 74 | 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/model/TripDetails.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.model 6 | 7 | import android.os.Parcelable 8 | import kotlinx.android.parcel.Parcelize 9 | 10 | 11 | @Parcelize 12 | data class TripDetails ( 13 | val spaceCraft: String, 14 | val station: String, 15 | val orbit: String, 16 | val type: String, 17 | val fair_1: String = "-", 18 | val fair_2: String = "-", 19 | val fair_3: String = "-", 20 | val btc_1: String = "-", 21 | val btc_2: String = "-", 22 | val btc_3: String = "-" 23 | ) : Parcelable -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/ui/viewmodel/StorageViewModel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.ui.viewmodel 6 | 7 | import androidx.lifecycle.ViewModel 8 | import androidx.lifecycle.asLiveData 9 | import androidx.lifecycle.viewModelScope 10 | import com.ibrajix.jetpacker.storage.DataStorage 11 | import dagger.hilt.android.lifecycle.HiltViewModel 12 | import kotlinx.coroutines.launch 13 | import javax.inject.Inject 14 | 15 | @HiltViewModel 16 | class StorageViewModel @Inject constructor(private val dataStorage: DataStorage) : ViewModel() { 17 | 18 | val walletBalance = dataStorage.getWalletBalance().asLiveData() 19 | fun changeWalletBalance(balance: String){ 20 | viewModelScope.launch { 21 | dataStorage.setWalletBalance(balance) 22 | } 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/utils/Constants.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.utils 6 | 7 | object Constants { 8 | 9 | const val SPLASH_SCREEN_TIME = 3500L 10 | 11 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/utils/FragmentViewBindingDelegate.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.utils 6 | 7 | 8 | import android.view.View 9 | import androidx.fragment.app.Fragment 10 | import androidx.lifecycle.DefaultLifecycleObserver 11 | import androidx.lifecycle.Lifecycle 12 | import androidx.lifecycle.LifecycleOwner 13 | import androidx.lifecycle.Observer 14 | import androidx.viewbinding.ViewBinding 15 | import kotlin.properties.ReadOnlyProperty 16 | import kotlin.reflect.KProperty 17 | 18 | /** 19 | * This class is used for simplifying viewBinding declarations in fragment, this way you don't have to call fragments onDestroy to nullify the binding every time 20 | */ 21 | 22 | class FragmentViewBindingDelegate( 23 | val fragment: Fragment, 24 | val viewBindingFactory: (View) -> T 25 | ) : ReadOnlyProperty { 26 | private var binding: T? = null 27 | 28 | init { 29 | fragment.lifecycle.addObserver(object : DefaultLifecycleObserver { 30 | val viewLifecycleOwnerLiveDataObserver = 31 | Observer { 32 | val viewLifecycleOwner = it ?: return@Observer 33 | 34 | viewLifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver { 35 | override fun onDestroy(owner: LifecycleOwner) { 36 | binding = null 37 | } 38 | }) 39 | } 40 | 41 | override fun onCreate(owner: LifecycleOwner) { 42 | fragment.viewLifecycleOwnerLiveData.observeForever(viewLifecycleOwnerLiveDataObserver) 43 | } 44 | 45 | override fun onDestroy(owner: LifecycleOwner) { 46 | fragment.viewLifecycleOwnerLiveData.removeObserver(viewLifecycleOwnerLiveDataObserver) 47 | } 48 | }) 49 | } 50 | 51 | override fun getValue(thisRef: Fragment, property: KProperty<*>): T { 52 | val binding = binding 53 | if (binding != null) { 54 | return binding 55 | } 56 | 57 | val lifecycle = fragment.viewLifecycleOwner.lifecycle 58 | if (!lifecycle.currentState.isAtLeast(Lifecycle.State.INITIALIZED)) { 59 | throw IllegalStateException("Should not attempt to get bindings when Fragment views are destroyed.") 60 | } 61 | 62 | return viewBindingFactory(thisRef.requireView()).also { this.binding = it } 63 | } 64 | 65 | } 66 | 67 | fun Fragment.viewBinding(viewBindingFactory: (View) -> T) = 68 | FragmentViewBindingDelegate(this, viewBindingFactory) -------------------------------------------------------------------------------- /app/src/main/java/com/ibrajix/jetpacker/utils/Utility.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Written and Developed by Inuwa Ibrahim - https://linktr.ee/Ibrajix 3 | */ 4 | 5 | package com.ibrajix.jetpacker.utils 6 | 7 | import android.annotation.SuppressLint 8 | import android.app.Activity 9 | import android.graphics.Color 10 | import android.view.LayoutInflater 11 | import android.view.View 12 | import androidx.appcompat.app.AppCompatActivity 13 | import androidx.viewbinding.ViewBinding 14 | 15 | 16 | @Suppress("DEPRECATION") 17 | @SuppressLint("InlinedApi") 18 | object Utility { 19 | 20 | //faster view binding in activity 21 | inline fun AppCompatActivity.viewBinding( 22 | crossinline bindingInflater: (LayoutInflater) -> T 23 | ) = lazy(LazyThreadSafetyMode.NONE) { 24 | bindingInflater.invoke(layoutInflater) 25 | } 26 | 27 | //make status bar color white 28 | fun Activity.whiteStatusBar(){ 29 | window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; 30 | window.statusBarColor = Color.WHITE 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_solid_border.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/et_round_border.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_back.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_empty_wallet.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_location.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_logo.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_main_logo_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_mark_green.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_rocket_falcon.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 | 33 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_start_journey.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 9 | 12 | 15 | 18 | 21 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/lyt_with_border_and_stroke.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/lyt_with_solid_border_grey.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/lyt_with_solid_border_main_orange.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/lyt_with_solid_border_orange_opaque.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/font/avenir_black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibrajix/JetPacker/f4e01e506acb3d0fcae66c05e877b45e5216d405/app/src/main/res/font/avenir_black.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/avenir_regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibrajix/JetPacker/f4e01e506acb3d0fcae66c05e877b45e5216d405/app/src/main/res/font/avenir_regular.ttf -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_container.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 21 | 22 | 33 | 34 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_enjoy_ride.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 23 | 24 | 30 | 31 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_fund_wallet.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 30 | 31 | 41 | 42 | 53 | 54 | 63 | 64 |