diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 017f895..0e0a007 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -1,9 +1,8 @@
plugins {
- id(BuildSystem.plugins.
- androidApplication)
+ id(BuildSystem.plugins.androidApplication)
id(BuildSystem.plugins.kotlinAndroid)
- id(BuildSystem.plugins.extensions)
id("com.google.gms.google-services")
+ id("kotlin-kapt")
id("org.jetbrains.kotlin.android")
}
@@ -13,6 +12,8 @@ apply {
android {
+ namespace = "com.teavaro.ecommDemoApp"
+
defaultConfig {
applicationId = "com.teavaro.ecommDemoApp"
minSdk = BuildSystem.versions.minSdk
@@ -34,10 +35,14 @@ android {
}
viewBinding {
- isEnabled = true
+ enable = true
+ }
+
+ buildFeatures {
+ buildConfig = true
}
- packagingOptions {
+ packaging {
resources.excludes.addAll(listOf(
"META-INF/DEPENDENCIES",
"META-INF/LICENSE-notice.md",
@@ -62,6 +67,15 @@ android {
}
}
}
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_17.toString()
+ }
}
dependencies {
@@ -82,26 +96,35 @@ dependencies {
* Ref: https://stackoverflow.com/a/70870040/6927433
*/
implementation(BuildSystem.libraries.androidXWorkRuntime)
- // Hyperion debugger
- debugImplementation(BuildSystem.libraries.hyperionCore)
- debugImplementation(BuildSystem.libraries.hyperionSharedPreferences)
- releaseImplementation(BuildSystem.libraries.hyperionNoop)
+ // Swrve
implementation(BuildSystem.libraries.swrve)
implementation(BuildSystem.libraries.swrveGeo)
- implementation(BuildSystem.libraries.teavaroSDK)
implementation(BuildSystem.libraries.googleServices)
+ //FunnelConnect and UTIQ
+ implementation("com.github.Teavaro.FunnelConnect-Mobile-SDK:funnelConnect:0.1.41")
+ {
+ exclude("com.github.Teavaro.FunnelConnect-Mobile-SDK", "core-android")
+ }
+ implementation("com.github.Utiq-tech.UTIQ-Mobile-SDK:utiq:0.1.55")
//
- implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1")
- implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1")
- implementation("androidx.navigation:navigation-fragment-ktx:2.3.5")
- implementation("androidx.navigation:navigation-ui-ktx:2.3.5")
- implementation ("com.google.code.gson:gson:2.8.2")
-
- testImplementation("junit:junit:4.13.2")
+ val lifecycleVersion = "2.8.3"
+ val navigationVersion = "2.7.7"
+ implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion")
+ implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion")
+ implementation("androidx.navigation:navigation-fragment-ktx:$navigationVersion")
+ implementation("androidx.navigation:navigation-ui-ktx:$navigationVersion")
+ implementation ("com.google.code.gson:gson:2.10.1")
- val room_version = "2.3.0" // check latest version from docs
+ // Hyperion debugger
+ //debugImplementation(BuildSystem.libraries.hyperionCore)
+ //debugImplementation(BuildSystem.libraries.hyperionSharedPreferences)
+ //releaseImplementation(BuildSystem.libraries.hyperionNoop)
- implementation("androidx.room:room-runtime:$room_version")
- annotationProcessor("androidx.room:room-compiler:$room_version")
-}
\ No newline at end of file
+ testImplementation("junit:junit:4.13.2")
+ //Room
+ val roomVersion = "2.6.1"
+ implementation("androidx.room:room-runtime:$roomVersion")
+ annotationProcessor("androidx.room:room-compiler:$roomVersion")
+ kapt("androidx.room:room-compiler:$roomVersion")
+ }
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/teavaro/ecommDemoApp/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/teavaro/ecommDemoApp/ExampleInstrumentedTest.kt
index 23695a2..28f9546 100644
--- a/app/src/androidTest/java/com/teavaro/ecommDemoApp/ExampleInstrumentedTest.kt
+++ b/app/src/androidTest/java/com/teavaro/ecommDemoApp/ExampleInstrumentedTest.kt
@@ -1,24 +1,24 @@
package com.teavaro.ecommDemoApp
-import androidx.test.platform.app.InstrumentationRegistry
-import androidx.test.ext.junit.runners.AndroidJUnit4
-
-import org.junit.Test
-import org.junit.runner.RunWith
-
-import org.junit.Assert.*
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-@RunWith(AndroidJUnit4::class)
-class ExampleInstrumentedTest {
- @Test
- fun useAppContext() {
- // Context of the app under test.
- val appContext = InstrumentationRegistry.getInstrumentation().targetContext
- assertEquals("com.teavaro.teavarodemoapp", appContext.packageName)
- }
-}
\ No newline at end of file
+//import androidx.test.platform.app.InstrumentationRegistry
+//import androidx.test.ext.junit.runners.AndroidJUnit4
+//
+//import org.junit.Test
+//import org.junit.runner.RunWith
+//
+//import org.junit.Assert.*
+//
+///**
+// * Instrumented test, which will execute on an Android device.
+// *
+// * See [testing documentation](http://d.android.com/tools/testing).
+// */
+//@RunWith(AndroidJUnit4::class)
+//class ExampleInstrumentedTest {
+// @Test
+// fun useAppContext() {
+// // Context of the app under test.
+// val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+// assertEquals("com.teavaro.teavarodemoapp", appContext.packageName)
+// }
+//}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1df6569..e4cf295 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,22 +1,23 @@
+ xmlns:tools="http://schemas.android.com/tools"
+ package="com.teavaro.ecommDemoApp">
+
-
+
-
@@ -30,7 +31,16 @@
+
+
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/app/src/main/app_icon-playstore.png b/app/src/main/app_icon-playstore.png
new file mode 100644
index 0000000..0b0a368
Binary files /dev/null and b/app/src/main/app_icon-playstore.png differ
diff --git a/app/src/main/java/com/teavaro/ecommDemoApp/MyBroadcastReceiver.java b/app/src/main/java/com/teavaro/ecommDemoApp/MyBroadcastReceiver.java
new file mode 100644
index 0000000..dd03c87
--- /dev/null
+++ b/app/src/main/java/com/teavaro/ecommDemoApp/MyBroadcastReceiver.java
@@ -0,0 +1,15 @@
+package com.teavaro.ecommDemoApp;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class MyBroadcastReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // Handle the broadcast event
+ Log.d("MyBroadcastReceiver", "Broadcast received");
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/teavaro/ecommDemoApp/core/Item.kt b/app/src/main/java/com/teavaro/ecommDemoApp/core/Item.kt
deleted file mode 100644
index c9e891a..0000000
--- a/app/src/main/java/com/teavaro/ecommDemoApp/core/Item.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.teavaro.ecommDemoApp.core
-
-data class Item (
- var id: Int,
- var title: String,
- var description: String,
- var price: Float,
- var picture: String,
- var isOffer: Boolean = false,
- var isInStock: Boolean = true,
- var isWish: Boolean = false,
- var countOnCart: Int = 0
-)
\ No newline at end of file
diff --git a/app/src/main/java/com/teavaro/ecommDemoApp/core/LogInMenu.kt b/app/src/main/java/com/teavaro/ecommDemoApp/core/LogInMenu.kt
deleted file mode 100644
index 0d8f3e1..0000000
--- a/app/src/main/java/com/teavaro/ecommDemoApp/core/LogInMenu.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.teavaro.ecommDemoApp.core
-
-import android.view.Menu
-
-object LogInMenu {
- lateinit var menu: Menu
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/teavaro/ecommDemoApp/core/PushNotification.kt b/app/src/main/java/com/teavaro/ecommDemoApp/core/PushNotification.kt
deleted file mode 100644
index 231cad3..0000000
--- a/app/src/main/java/com/teavaro/ecommDemoApp/core/PushNotification.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.teavaro.ecommDemoApp.core
-
-import java.io.BufferedInputStream
-import java.io.InputStream
-import java.net.HttpURLConnection
-import java.net.URL
-
-object PushNotification {
-
- private const val swrveKeyCampaign = "708f47c5-e22d-457b-9d34-4cd35a160acb"
- private const val URL = "https://service.swrve.com/push?push_key=$swrveKeyCampaign"
-
- fun send(user: String?, message: String?): String {
- return try {
- if(user != null && message != null) {
- val url = URL("$URL&user=$user")
- val urlConnection: HttpURLConnection = url.openConnection() as HttpURLConnection
- urlConnection.requestMethod = "POST"
- try {
- val response: InputStream = BufferedInputStream(urlConnection.inputStream)
- response.toString()
- } finally {
- urlConnection.disconnect()
- }
- }
- else
- ""
- } catch (e: java.lang.Exception){
- "DemoApp: $e"
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/teavaro/ecommDemoApp/core/SharedPreferenceUtils.kt b/app/src/main/java/com/teavaro/ecommDemoApp/core/SharedPreferenceUtils.kt
deleted file mode 100644
index 1455f82..0000000
--- a/app/src/main/java/com/teavaro/ecommDemoApp/core/SharedPreferenceUtils.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.teavaro.ecommDemoApp.core
-
-import android.content.Context
-
-object SharedPreferenceUtils {
-
- private const val STUB_MODE = "STUB_MODE"
-
- private fun getSharedPreferences(context: Context) = context.getSharedPreferences("MySharedPreferences", Context.MODE_PRIVATE)
-
- fun isStubMode(context: Context) = this.getSharedPreferences(context).getBoolean(STUB_MODE, false)
-
- fun setStubMode(context: Context, value: Boolean) {
- this.getSharedPreferences(context).edit().putBoolean(STUB_MODE, value).apply()
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/teavaro/ecommDemoApp/core/Store.kt b/app/src/main/java/com/teavaro/ecommDemoApp/core/Store.kt
index 3e7ddba..4161edb 100644
--- a/app/src/main/java/com/teavaro/ecommDemoApp/core/Store.kt
+++ b/app/src/main/java/com/teavaro/ecommDemoApp/core/Store.kt
@@ -1,66 +1,120 @@
package com.teavaro.ecommDemoApp.core
+import android.annotation.SuppressLint
+import android.app.Activity
import android.content.Context
+import android.content.Intent
+import android.net.Uri
import android.util.Log
+import android.webkit.WebView
+import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import com.google.gson.Gson
-import com.teavaro.ecommDemoApp.ui.PermissionConsentDialogFragment
-import com.teavaro.funnelConnect.core.initializer.FunnelConnectSDK
-import com.teavaro.funnelConnect.utils.platformTypes.permissionsMap.PermissionsMap
+import com.google.gson.reflect.TypeToken
+import com.swrve.sdk.SwrveSDK
+import com.swrve.sdk.geo.SwrveGeoSDK
+import com.teavaro.ecommDemoApp.R
+import com.teavaro.ecommDemoApp.core.dataClases.InfoResponse
+import com.teavaro.ecommDemoApp.core.room.ACEntity
+import com.teavaro.ecommDemoApp.core.room.AppDb
+import com.teavaro.ecommDemoApp.core.room.ItemEntity
+import com.teavaro.ecommDemoApp.core.utils.SharedPreferenceUtils
+import com.teavaro.ecommDemoApp.core.utils.TrackUtils
+import com.teavaro.ecommDemoApp.ui.AbandonedCartDialogFragment
+import com.teavaro.ecommDemoApp.ui.ItemDescriptionDialogFragment
+import com.teavaro.ecommDemoApp.ui.permissions.PermissionConsentDialogFragment
+import com.teavaro.ecommDemoApp.ui.permissions.UtiqConsent
+import com.teavaro.funnelConnect.main.FunnelConnectSDK
+import com.teavaro.funnelConnect.utils.platformTypes.permissionsMap.Permissions
+import com.utiq.utiqTech.main.Utiq
+import org.json.JSONObject
+import java.lang.reflect.Type
+import java.net.URLEncoder
+
+@SuppressLint("StaticFieldLeak")
object Store {
- private var listItems: ArrayList- = ArrayList()
- var section = ""
- var isLogin = false
- var infoResponse: String = "{}"
- val notificationName = "APP_CS"
- val notificationVersion = 4
- var description = "There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don’t look even slightly believable. If you are going to use a passage of Lorem Ipsum."
-
- init {
- listItems.add(Item(0, "Jacob’s Baked Crinklys Cheese", description,60.00f, "crinklys", true))
- listItems.add(Item(1, "Pork Cocktail Sausages, Pack", description, 54.00f, "pork", true, false))
- listItems.add(Item(2, "Broccoli and Cauliflower Mix", description, 6.00f, "cauliflower"))
- listItems.add(Item(3, "Morrisons Creamed Rice Pudding", description, 44.00f, "paprika"))
- listItems.add(Item(4, "Fresh For The Bold Ground Amazon", description, 12.00f, "burst"))
- listItems.add(Item(5, "Frito-Lay Doritos & Cheetos Mix", description, 20.00f, "watermelon"))
- listItems.add(Item(6, "Green Mountain Coffee Roast", description, 20.00f, "grapes"))
- listItems.add(Item(7, "Nature’s Bakery Whole Wheat Bars", description, 50.00f, "mixed"))
- }
+ val stubToken = "523393b9b7aa92a534db512af83084506d89e965b95c36f982200e76afcb82cb"
+ private var db: AppDb? = null
+ var listItems: ArrayList = ArrayList()
+ var listOffers: ArrayList = ArrayList()
+ var listCart: ArrayList = ArrayList()
+ var listWish: ArrayList = ArrayList()
+ var listAc: ArrayList = ArrayList()
+ var section = "none"
+ var webView: WebView? = null
+ var navigateAction: ((Int) -> Unit)? = null
+ var infoResponse: String? = null
+ var attributes: String? = null
+ val keyOm = "CS-OM"
+ val keyOpt = "CS-OPT"
+ val keyNba = "CS-NBA"
+ val keyUtiq = "CS-UTIQ"
+ val fcNotificationsName = "MAIN_CS"
+ val utiqNotificationsName = "UTIQ_CS"
+ val notificationsVersion = 1
+ val userType = "enemail"
+ var atid: String = "UTIQ not initialized."
+ var mtid: String = "UTIQ not initialized."
+ var umid: String? = "FunnelConnect not initialized."
+ var userId: String? = null
+ var itemId = ""
+ var isFunnelConnectStarted = false
+ var description =
+ "There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don’t look even slightly believable. If you are going to use a passage of Lorem Ipsum."
+ var refreshCeltraAd: (() -> Unit)? = null
fun addItemToCart(id: Int) {
- listItems[id].countOnCart += 1
+ listItems[id].countInCart += 1
+ updateItemDB(listItems[id])
+ listCart = getItemsCart()
}
fun removeItemFromCart(id: Int) {
- listItems[id].countOnCart = 0
+ listItems[id].countInCart = 0
+ updateItemDB(listItems[id])
+ listCart = getItemsCart()
+ }
+
+ fun updateItemDB(item: ItemEntity) {
+ db?.let {
+ Thread {
+ it.itemDao().update(item)
+ }.start()
+ }
}
fun addItemToWish(id: Int) {
- listItems[id].isWish = true
+ listItems[id].isInWish = true
+ updateItemDB(listItems[id])
+ listWish = getItemsWish()
}
fun removeItemFromWish(id: Int) {
- listItems[id].isWish = false
+ listItems[id].isInWish = false
+ updateItemDB(listItems[id])
+ listWish = getItemsWish()
}
- fun getItems(): ArrayList
- {
+ fun getItems(): ArrayList {
return listItems
}
- fun getItemsCart(): ArrayList
- {
- val listCart = ArrayList
- ()
+ fun getItemsCart(): ArrayList {
+ val listCart = ArrayList()
for (item in listItems) {
- if (item.countOnCart > 0)
+ if (item.countInCart > 0) {
listCart.add(item)
+ }
}
return listCart
}
- fun getItemsWish(): ArrayList
- {
- val listWish = ArrayList
- ()
+ fun getItemsWish(): ArrayList {
+ val listWish = ArrayList()
for (item in listItems) {
- if (item.isWish)
+ if (item.isInWish)
listWish.add(item)
}
return listWish
@@ -69,13 +123,13 @@ object Store {
fun getTotalPriceCart(): Float {
var total = 0f
for (item in listItems) {
- total += item.price * item.countOnCart
+ total += item.price * item.countInCart
}
return total
}
- fun getItemsOffer(): ArrayList
- {
- val listOffer = ArrayList
- ()
+ fun getItemsOffer(): ArrayList {
+ val listOffer = ArrayList()
for (item in listItems) {
if (item.isOffer)
listOffer.add(item)
@@ -85,75 +139,502 @@ object Store {
fun removeAllCartItems() {
for (item in listItems) {
- item.countOnCart = 0
+ if (item.countInCart > 0) {
+ item.countInCart = 0
+ updateItemDB(item)
+ }
}
}
- fun showPermissionsDialog(context: Context, supportFragmentManager: FragmentManager) {
+ fun showPermissionsDialog(context: Activity, supportFragmentManager: FragmentManager) {
PermissionConsentDialogFragment.open(
supportFragmentManager,
{ omPermissionAccepted, optPermissionAccepted, nbaPermissionAccepted ->
- val permissions = PermissionsMap()
- permissions.addPermission("CS-TMI",omPermissionAccepted)
- permissions.addPermission("CS-OPT",optPermissionAccepted)
- permissions.addPermission("CS-NBA",nbaPermissionAccepted)
- FunnelConnectSDK.cdp().updatePermissions(permissions, notificationName,notificationVersion)
- if(nbaPermissionAccepted) {
- FunnelConnectSDK.trustPid().acceptConsent()
- val isStub = SharedPreferenceUtils.isStubMode(context)
- FunnelConnectSDK.trustPid().startService(isStub)
+ updatePermissions(
+ omPermissionAccepted,
+ optPermissionAccepted,
+ nbaPermissionAccepted,
+ context
+ )
+ if (omPermissionAccepted || optPermissionAccepted || nbaPermissionAccepted) {
+ val stubToken = SharedPreferenceUtils.getStubToken(context)
+ Utiq.checkMNOEligibility(stubToken, {
+ showUtiqConsent(context, supportFragmentManager)
+ }, {
+
+ })
+ } else {
+ clearData(context)
}
- else
- FunnelConnectSDK.trustPid().rejectConsent()
},
{
- FunnelConnectSDK.trustPid().rejectConsent()
- val permissions = PermissionsMap()
- permissions.addPermission("CS-TMI",false)
- permissions.addPermission("CS-OPT",false)
- permissions.addPermission("CS-NBA",false)
- FunnelConnectSDK.cdp().updatePermissions(permissions, notificationName,notificationVersion)
+ updatePermissions(
+ om = false,
+ opt = false,
+ nba = false,
+ context
+ )
+ clearData(context)
})
}
- fun getBanner(): String{
- var text = ""
- var gson = Gson()
- var obj: InfoResponse = gson.fromJson(infoResponse, InfoResponse::class.java)
- obj?.let { ob ->
- ob.attributes?.let { attr ->
- attr.forEach {
- text += "&" + it.key + "=" + it.value
+ fun showUtiqConsent(context: Activity, supportFragmentManager: FragmentManager) {
+ UtiqConsent.open(supportFragmentManager) { consent ->
+ if (Utiq.isInitialized()) {
+ if (consent) {
+ Utiq.acceptConsent()
+ utiqStartService(context)
+ } else {
+ Utiq.rejectConsent()
+ }
+ updateUtiqConsent(consent, context)
+ }
+ }
+ }
+
+ private fun updateUtiqConsent(
+ consent: Boolean,
+ context: Activity
+ ) {
+ val action = {
+ val permissions = Permissions()
+ permissions.addPermission(keyUtiq, consent)
+ FunnelConnectSDK.updatePermissions(
+ permissions,
+ utiqNotificationsName,
+ notificationsVersion, {
+ updateFCData(it)
+ }
+ )
+ }
+ if (isFunnelConnectStarted) {
+ action.invoke()
+ } else {
+ fcStartService(context) {
+ action.invoke()
+ }
+ }
+ }
+
+ fun updatePermissions(
+ om: Boolean,
+ opt: Boolean,
+ nba: Boolean,
+ context: Activity
+ ) {
+ val action = {
+ val permissions = Permissions()
+ permissions.addPermission(keyOm, om)
+ permissions.addPermission(keyOpt, opt)
+ permissions.addPermission(keyNba, nba)
+ FunnelConnectSDK.updatePermissions(
+ permissions,
+ fcNotificationsName,
+ notificationsVersion, {
+ updateFCData(it)
+ }
+ )
+ }
+ if (isFunnelConnectStarted) {
+ action.invoke()
+ } else {
+ fcStartService(context) {
+ action.invoke()
+ }
+ }
+ }
+
+ fun showAbandonedCartDialog(supportFragmentManager: FragmentManager, items: List) {
+ AbandonedCartDialogFragment.open(
+ supportFragmentManager,
+ items
+ ) {
+ it.forEach { item ->
+ addItemToCart(item.itemId)
+ }
+ navigateAction?.invoke(R.id.navigation_cart)
+ }
+ }
+
+ fun getAttributesFromInfo(): String? {
+ infoResponse?.let { info ->
+ var gson = Gson()
+ val classOb = InfoResponse::class.java
+ classOb?.let { classOnj ->
+ var obj: InfoResponse? = gson.fromJson(info, classOnj)
+ obj?.let { ob ->
+ ob.attributes?.let { attr ->
+ val gsonType: Type = object : TypeToken?>() {}.type
+ return gson.toJson(attr, gsonType)
+ }
}
}
}
- Log.d("iran:infoResponse", infoResponse)
- Log.d("iran:attr", text)
+ return null
+ }
+
+ fun getBanner(): String {
+ var text = "&attributes=${URLEncoder.encode("{}", "utf-8")}"
+ if (isNbaPermissionAccepted()) {
+ attributes?.let {
+ text = "&attributes=${URLEncoder.encode(it, "utf-8")}"
+ }
+ text += "&allowTracking=true"
+ } else {
+ text += "&allowTracking=false"
+ }
return """
-
-
-
+
+
+
-
+