1 // Copyright 2015-present 650 Industries. All rights reserved.
2 package host.exp.exponent.kernel
3 
4 import host.exp.exponent.analytics.EXL
5 import host.exp.exponent.experience.DetachActivity
6 import host.exp.exponent.notifications.ExponentNotification
7 
8 object KernelConstants {
9   val TAG = KernelConstants::class.java.simpleName
10 
11   const val MANIFEST_URL_KEY = "experienceUrl"
12   const val NOTIFICATION_MANIFEST_URL_KEY = "notificationExperienceUrl"
13   const val NOTIFICATION_ACTION_TYPE_KEY = "actionType"
14 
15   // TODO: Remove once we decide to stop supporting shortcuts to experiences.
16   const val SHORTCUT_MANIFEST_URL_KEY = "shortcutExperienceUrl"
17   const val HOME_MANIFEST_URL = ""
18   const val LINKING_URI_KEY = "linkingUri"
19   const val INTENT_URI_KEY = "intentUri"
20   const val IS_HEADLESS_KEY = "isHeadless"
21   const val IS_OPTIMISTIC_KEY = "isOptimistic"
22   const val LOAD_FROM_CACHE_KEY = "loadFromCache"
23   const val BUNDLE_TAG = "BUNDLE"
24   const val HOME_MODULE_NAME = "main"
25   const val BUNDLE_FILE_PREFIX = "cached-bundle-"
26   const val KERNEL_BUNDLE_ID = "kernel"
27   const val OPEN_OPTIMISTIC_EXPERIENCE_ACTIVITY_KEY = "openOptimisticExperienceActivity"
28   const val OPEN_EXPERIENCE_ACTIVITY_KEY = "openExperienceActivity"
29   const val LOAD_BUNDLE_FOR_EXPERIENCE_ACTIVITY_KEY = "loadBundleForExperienceActivity"
30   const val EXPERIENCE_ID_SET_FOR_ACTIVITY_KEY = "experienceIdSetForActivity"
31   const val HTTP_NOT_MODIFIED = 304
32   const val OVERLAY_PERMISSION_REQUEST_CODE = 123
33   const val DEFAULT_APPLICATION_KEY = "main"
34   const val NOTIFICATION_KEY = "notification"
35   const val NOTIFICATION_ID_KEY = "notification_id"
36   const val NOTIFICATION_OBJECT_KEY = "notification_object"
37 
38   var MAIN_ACTIVITY_CLASS: Class<*> = DetachActivity::class.java
39   init {
40     try {
41       MAIN_ACTIVITY_CLASS = Class.forName("host.exp.exponent.MainActivity")
42     } catch (e: Exception) {
43       EXL.e(TAG, "Could not find MainActivity, falling back to DetachActivity: " + e.message)
44     }
45   }
46 
47   class ExperienceOptions {
48     val manifestUri: String
49     val uri: String?
50     @Deprecated("deprecated") val notification: String?
51     val notificationObject: ExponentNotification?
52 
53     constructor(manifestUri: String, uri: String?, notification: String?) {
54       this.manifestUri = manifestUri
55       this.uri = uri
56       this.notification = notification
57       this.notificationObject = null
58     }
59 
60     constructor(
61       manifestUri: String,
62       uri: String?,
63       notification: String?,
64       notificationObject: ExponentNotification?
65     ) {
66       this.manifestUri = manifestUri
67       this.uri = uri
68       this.notification = notification
69       this.notificationObject = notificationObject
70     }
71   }
72 
73   data class ExperienceEvent(val eventName: String, val eventPayload: String)
74   data class AddedExperienceEventEvent(val manifestUrl: String)
75 }
76