Skip to content

Commit a0febb3

Browse files
authored
feat: add nav, shop, detail screen (#9)
1 parent 9419278 commit a0febb3

Some content is hidden

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

48 files changed

+1251
-41
lines changed

core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,25 @@ plugins {
66
id("com.android.application")
77
id("org.jlleitschuh.gradle.ktlint") version "10.2.1"
88
kotlin("android")
9+
kotlin("kapt")
910
}
1011

1112
android {
1213
compileSdk = 31
1314
defaultConfig {
1415
applicationId = "com.mparticle.example.higgsshopsampleapp"
15-
minSdk = 16
16+
minSdk = 23
1617
targetSdk = 31
1718
versionCode = buildVersionCode()
1819
versionName = "0.4.0-SNAPSHOT"
1920
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2021
buildConfigField("String", "HIGGS_SHOP_SAMPLE_APP_KEY", "\"${System.getenv("HIGGS_SHOP_SAMPLE_APP_KEY")}\"")
2122
buildConfigField("String", "HIGGS_SHOP_SAMPLE_APP_SECRET", "\"${System.getenv("HIGGS_SHOP_SAMPLE_APP_SECRET")}\"")
2223
}
24+
buildFeatures {
25+
dataBinding = true
26+
viewBinding = true
27+
}
2328
buildTypes {
2429
getByName("release") {
2530
isMinifyEnabled = false
@@ -29,24 +34,70 @@ android {
2934
isMinifyEnabled = false
3035
}
3136
}
37+
compileOptions {
38+
sourceCompatibility = JavaVersion.VERSION_11
39+
targetCompatibility = JavaVersion.VERSION_11
40+
}
3241
}
3342

3443
dependencies {
35-
implementation("androidx.core:core-ktx:1.7.0")
36-
implementation("androidx.constraintlayout:constraintlayout:2.1.3")
3744
implementation("androidx.appcompat:appcompat:1.4.1")
45+
implementation("androidx.fragment:fragment:1.3.6")
46+
implementation("androidx.fragment:fragment-ktx:1.3.6")
47+
implementation("androidx.constraintlayout:constraintlayout:2.1.3")
48+
implementation("androidx.core:core-ktx:1.7.0")
49+
implementation("androidx.recyclerview:recyclerview:1.2.1")
50+
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1")
3851
implementation("com.google.android.material:material:1.5.0")
3952
implementation("com.mparticle:android-core:5.35.3")
53+
54+
implementation("androidx.navigation:navigation-fragment:2.3.5")
55+
implementation("androidx.navigation:navigation-ui:2.3.5")
56+
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1")
57+
implementation("androidx.navigation:navigation-fragment-ktx:2.3.5")
58+
implementation("androidx.navigation:navigation-ui-ktx:2.3.5")
59+
60+
api("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.3.7")
61+
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
62+
api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1")
63+
64+
implementation("com.squareup.retrofit2:retrofit:2.6.1")
65+
implementation("com.squareup.retrofit2:converter-gson:2.6.1")
66+
implementation("com.squareup.retrofit2:converter-moshi:2.6.1")
67+
implementation("com.squareup.retrofit2:adapter-rxjava2:2.6.1")
68+
implementation("io.reactivex.rxjava2:rxjava:2.1.14")
69+
implementation("io.reactivex.rxjava2:rxandroid:2.0.2")
70+
implementation("com.squareup.okhttp3:logging-interceptor:3.12.12")
71+
implementation("com.squareup.okhttp3:okhttp:3.12.12")
72+
implementation("com.squareup.okhttp3:logging-interceptor:3.12.12")
73+
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1")
74+
implementation("androidx.navigation:navigation-fragment-ktx:2.3.5")
75+
implementation("androidx.navigation:navigation-ui-ktx:2.3.5")
76+
77+
val roomVersion = "2.4.1"
78+
implementation("androidx.room:room-runtime:$roomVersion")
79+
annotationProcessor("androidx.room:room-compiler:$roomVersion")
80+
kapt("androidx.room:room-compiler:$roomVersion")
81+
// ksp("androidx.room:room-compiler:$roomVersion")
82+
implementation("androidx.room:room-ktx:$roomVersion")
83+
// implementation("androidx.room:room-rxjava2:$roomVersion")
84+
// implementation("androidx.room:room-rxjava3:$roomVersion")
85+
// implementation("androidx.room:room-guava:$roomVersion")
86+
// implementation("androidx.room:room-paging:2.4.1")
87+
testImplementation("androidx.room:room-testing:$roomVersion")
88+
4089
testImplementation("junit:junit:4.13.2")
4190
androidTestImplementation("androidx.test:core:1.4.0")
4291
androidTestImplementation("androidx.test:core-ktx:1.4.0")
4392
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
93+
androidTestImplementation("androidx.test.espresso:espresso-intents:3.4.0")
4494
androidTestImplementation("androidx.test:rules:1.4.0")
4595
androidTestImplementation("androidx.test.ext:junit:1.1.3")
4696
androidTestImplementation("androidx.test.ext:junit-ktx:1.1.3")
4797
androidTestImplementation("androidx.test.ext:truth:1.4.0")
4898
androidTestImplementation("com.google.truth:truth:1.1.3")
4999
androidTestImplementation("androidx.test:runner:1.4.0")
100+
androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0")
50101
androidTestUtil("androidx.test:orchestrator:1.4.1")
51102
}
52103

core-sdk-samples/higgs-shop-sample-app/app/src/androidTest/kotlin/com/mparticle/example/higgsshopsampleapp/ExampleInstrumentedTests.kt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
package com.mparticle.example.higgsshopsampleapp
22

3-
import androidx.test.ext.junit.rules.activityScenarioRule
3+
import android.content.Intent
4+
import androidx.test.core.app.ApplicationProvider
45
import androidx.test.espresso.Espresso.onView
6+
import androidx.test.espresso.action.ViewActions.click
57
import androidx.test.espresso.assertion.ViewAssertions.matches
68
import androidx.test.espresso.matcher.ViewMatchers.withId
79
import androidx.test.espresso.matcher.ViewMatchers.withText
10+
import androidx.test.ext.junit.rules.activityScenarioRule
811
import androidx.test.filters.LargeTest
912
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
1013
import androidx.test.platform.app.InstrumentationRegistry
1114
import com.mparticle.example.higgsshopsampleapp.activities.LandingActivity
15+
import com.mparticle.example.higgsshopsampleapp.activities.MainActivity
16+
import com.mparticle.example.higgsshopsampleapp.repositories.network.ProductsRepository
1217
import org.junit.Assert.*
1318
import org.junit.Rule
1419
import org.junit.Test
1520
import org.junit.runner.RunWith
21+
import java.io.InputStream
1622

1723

1824
@RunWith(AndroidJUnit4ClassRunner::class)
1925
@LargeTest
2026
class ExampleInstrumentedTests {
2127

28+
val intent = Intent(ApplicationProvider.getApplicationContext(), MainActivity::class.java)
29+
2230
@get:Rule
23-
var activityScenarioRule = activityScenarioRule<LandingActivity>()
31+
var landingActivityScenarioRule = activityScenarioRule<LandingActivity>()
32+
33+
@get:Rule
34+
var mainActivityScenarioRule = activityScenarioRule<MainActivity>(intent)
2435

2536
@Test
2637
fun testUseAppContext() {
@@ -32,4 +43,24 @@ class ExampleInstrumentedTests {
3243
fun testShowLandingCTA() {
3344
onView(withId(R.id.landing_cta)).check(matches(withText(R.string.landing_cta)))
3445
}
46+
47+
@Test
48+
fun testClickLandingCTA() {
49+
onView(withId(R.id.landing_cta)).perform(click())
50+
onView(withId(R.id.tv_shop_header)).check(matches(withText(R.string.shop_title)))
51+
}
52+
53+
@Test
54+
fun testProductJsonFileExists() {
55+
val file: InputStream =
56+
InstrumentationRegistry.getInstrumentation().targetContext.assets.open("products.json")
57+
assertNotNull(file)
58+
}
59+
60+
@Test
61+
fun testProductCount() {
62+
val repository = ProductsRepository()
63+
val products = repository.getProducts(InstrumentationRegistry.getInstrumentation().targetContext)
64+
assertEquals(products.size, 13)
65+
}
3566
}

core-sdk-samples/higgs-shop-sample-app/app/src/main/AndroidManifest.xml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
android:label="@string/app_name"
1212
android:roundIcon="@mipmap/ic_launcher_round"
1313
android:supportsRtl="true"
14-
android:theme="@style/Theme.mParticle.Activity.Landing">
14+
android:theme="@style/Theme.mParticle.SampleApp">
1515
<activity
1616
android:name="com.mparticle.example.higgsshopsampleapp.activities.SplashActivity"
17-
android:theme="@style/Theme.mParticle.Activity.Landing"
17+
android:theme="@style/Theme.mParticle.SampleApp.Splash"
18+
android:screenOrientation="portrait"
1819
android:exported="true">
1920
<intent-filter>
2021
<action android:name="android.intent.action.MAIN" />
@@ -24,7 +25,21 @@
2425
</activity>
2526
<activity
2627
android:name="com.mparticle.example.higgsshopsampleapp.activities.LandingActivity"
27-
android:theme="@style/Theme.mParticle.Activity.Landing"
28+
android:theme="@style/Theme.mParticle.SampleApp.Splash"
29+
android:screenOrientation="portrait"
30+
android:exported="true">
31+
</activity>
32+
<activity
33+
android:name="com.mparticle.example.higgsshopsampleapp.activities.MainActivity"
34+
android:theme="@style/Theme.mParticle.SampleApp"
35+
android:screenOrientation="portrait"
36+
android:exported="true">
37+
<nav-graph android:value="@navigation/nav_graph" />
38+
</activity>
39+
<activity
40+
android:name="com.mparticle.example.higgsshopsampleapp.activities.ProductDetailActivity"
41+
android:theme="@style/Theme.mParticle.SampleApp"
42+
android:screenOrientation="portrait"
2843
android:exported="true">
2944
</activity>
3045
</application>
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
{
2+
"products": [{
3+
"id": "128740",
4+
"label": "mP Icon Full Zip",
5+
"imageUrl": "/products/128740.png",
6+
"altText": "mP Icon Full Zip",
7+
"price": 110.0,
8+
"category": "Apparel",
9+
"brand": "mParticle",
10+
"variants": {
11+
"colors": ["Black"],
12+
"sizes": ["S", "M", "L", "XL", "2XL"]
13+
},
14+
"description": "Description TBD"
15+
},
16+
{
17+
"id": "128744",
18+
"label": "Unisex Fleece Pullover",
19+
"imageUrl": "/products/128744.png",
20+
"altText": "Unisex Fleece Pullover",
21+
"price": 50.0,
22+
"category": "Apparel",
23+
"brand": "mParticle",
24+
"variants": {
25+
"colors": ["Deep Black"],
26+
"sizes": ["XS", "S", "M", "L", "XL", "2XL", "3XL", "4XL"]
27+
},
28+
"description": "Description TBD"
29+
},
30+
{
31+
"id": "128745",
32+
"label": "Unisex Full Logo Tee",
33+
"imageUrl": "/products/128745.png",
34+
"altText": "Unisex Full Logo Tee",
35+
"price": 9.0,
36+
"category": "Apparel",
37+
"brand": "mParticle",
38+
"variants": {
39+
"colors": [
40+
"Black Heather",
41+
"Dark Grey",
42+
"Storm",
43+
"True Royal",
44+
"Mustard",
45+
"Military Green",
46+
"Navy",
47+
"Orchid",
48+
"Dusty Blue"
49+
],
50+
"sizes": ["XS", "S", "M", "L", "XL", "2XL", "3XL", "4XL"]
51+
},
52+
"description": "Description TBD"
53+
},
54+
{
55+
"id": "128272",
56+
"label": "Women's Full Logo Tee",
57+
"imageUrl": "/products/128272.png",
58+
"altText": "Women's Full Logo Tee",
59+
"category": "Apparel",
60+
"brand": "mParticle",
61+
"price": 9.0,
62+
"variants": {
63+
"colors": [
64+
"Black Heather",
65+
"Dark Grey",
66+
"Storm",
67+
"True Royal",
68+
"Athletic Heather",
69+
"Sand Dune",
70+
"Military Green",
71+
"Navy",
72+
"Orchid",
73+
"Dusty Blue"
74+
],
75+
"sizes": ["S", "M", "L", "XL", "2XL"]
76+
},
77+
"description": "Description TBD"
78+
},
79+
{
80+
"id": "128747",
81+
"label": "Unisex Tee",
82+
"imageUrl": "/products/128747.png",
83+
"altText": "Unisex Tee",
84+
"category": "Apparel",
85+
"brand": "mParticle",
86+
"price": 8.0,
87+
"variants": {
88+
"colors": ["Dark Grey Heather"],
89+
"sizes": ["XS", "S", "M", "L", "XL", "2XL"]
90+
},
91+
"description": "Description TBD"
92+
},
93+
{
94+
"id": "128746",
95+
"label": "Unisex Pride Tee",
96+
"imageUrl": "/products/128746.png",
97+
"altText": "Unisex Pride Tee",
98+
"price": 14.0,
99+
"category": "Apparel",
100+
"brand": "mParticle",
101+
"variants": {
102+
"colors": ["Black"],
103+
"sizes": ["XS", "S", "M", "L", "XL", "2XL", "3XL", "4XL"]
104+
},
105+
"description": "Description TBD"
106+
},
107+
{
108+
"id": "128737",
109+
"label": "Absobu Dog Bowl",
110+
"imageUrl": "/products/128737.png",
111+
"altText": "Absobu Dog Bowl",
112+
"price": 28.0,
113+
"category": "Swag",
114+
"brand": "Absobu",
115+
"description": "Description TBD"
116+
},
117+
{
118+
"id": "128741",
119+
"label": "Pride Decal",
120+
"imageUrl": "/products/128741.png",
121+
"altText": "Pride Decal",
122+
"price": 3.0,
123+
"category": "Stickers",
124+
"brand": "mParticle",
125+
"description": "Description TBD"
126+
},
127+
{
128+
"id": "128113",
129+
"label": "Gamer Sticker",
130+
"imageUrl": "/products/128113.png",
131+
"altText": "Gamer Sticker",
132+
"price": 1.0,
133+
"category": "Stickers",
134+
"brand": "Higgs",
135+
"description": "2.3' W x 2.25' H"
136+
},
137+
{
138+
"id": "128115",
139+
"label": "Mug Sticker",
140+
"imageUrl": "/products/128115.png",
141+
"altText": "Mug Sticker",
142+
"price": 1.0,
143+
"category": "Stickers",
144+
"brand": "Higgs",
145+
"description": "2.25' W x 2.1' H"
146+
},
147+
{
148+
"id": "128114",
149+
"label": "Glasses Sticker",
150+
"imageUrl": "/products/128114.png",
151+
"altText": "Glasses Sticker",
152+
"price": 1.0,
153+
"category": "Stickers",
154+
"brand": "Higgs",
155+
"description": "2' W x 2.25' H"
156+
},
157+
{
158+
"id": "128742",
159+
"label": "Pride Sticker",
160+
"imageUrl": "/products/128742.png",
161+
"altText": "Pride Sticker",
162+
"price": 2.0,
163+
"category": "Stickers",
164+
"brand": "mParticle",
165+
"description": "Description TBD"
166+
},
167+
{
168+
"id": "128743",
169+
"label": "Tennis Ball",
170+
"imageUrl": "/products/128743.png",
171+
"altText": "Tennis Ball",
172+
"price": 2.0,
173+
"category": "Toys",
174+
"brand": "mParticle",
175+
"description": "Description TBD"
176+
}
177+
]
178+
}

0 commit comments

Comments
 (0)