-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMendixNativeModule.kt
More file actions
183 lines (148 loc) · 5.6 KB
/
Copy pathMendixNativeModule.kt
File metadata and controls
183 lines (148 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package com.mendixnative
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.WritableMap
import com.facebook.react.module.annotations.ReactModule
import com.mendix.mendixnative.encryption.MendixEncryptedStorageModule
import com.mendix.mendixnative.react.MxConfiguration
import com.mendix.mendixnative.react.NativeErrorHandler
import com.mendix.mendixnative.react.NativeReloadHandler
import com.mendix.mendixnative.react.NavigationModeModule
import com.mendix.mendixnative.react.cookie.NativeCookieModule
import com.mendix.mendixnative.react.download.NativeDownloadModule
import com.mendix.mendixnative.react.fs.NativeFsModule
import com.mendix.mendixnative.react.ota.NativeOtaModule
import com.mendix.mendixnative.react.splash.MendixSplashScreenModule
import com.mendix.mendixnative.react.splash.MendixSplashScreenPresenter
@ReactModule(name = MendixNativeModule.NAME)
class MendixNativeModule(reactContext: ReactApplicationContext) : NativeMendixNativeSpec(reactContext) {
var presenter: MendixSplashScreenPresenter? = null
override fun getName(): String {
return NAME
}
override fun encryptedStorageSetItem(key: String, value: String, promise: Promise) {
MendixEncryptedStorageModule(reactApplicationContext).setItem(key, value, promise)
}
override fun encryptedStorageGetItem(key: String, promise: Promise) {
MendixEncryptedStorageModule(reactApplicationContext).getItem(key, promise)
}
override fun encryptedStorageRemoveItem(key: String, promise: Promise) {
MendixEncryptedStorageModule(reactApplicationContext).removeItem(key, promise)
}
override fun encryptedStorageClear(promise: Promise) {
MendixEncryptedStorageModule(reactApplicationContext).clear(promise)
}
override fun encryptedStorageIsEncrypted(): Boolean {
return MendixEncryptedStorageModule(reactApplicationContext).isEncrypted
}
override fun splashScreenShow() {
MendixSplashScreenModule(reactApplicationContext).show(presenter)
}
override fun splashScreenHide() {
MendixSplashScreenModule(reactApplicationContext).hide(presenter)
}
override fun cookieClearAll(promise: Promise) {
NativeCookieModule(reactApplicationContext).clearAll(promise)
}
override fun reloadHandlerReload(promise: Promise) {
NativeReloadHandler(reactApplicationContext).reload()
promise.resolve(null)
}
fun reloadClientWithState() {
emitOnReloadWithState()
}
override fun reloadHandlerExitApp(promise: Promise) {
NativeReloadHandler(reactApplicationContext).exitApp()
promise.resolve(null)
}
override fun downloadHandlerDownload(
url: String,
downloadPath: String,
config: ReadableMap,
promise: Promise
) {
NativeDownloadModule(reactApplicationContext).download(
url, downloadPath, config, promise
)
}
override fun mxConfigurationGetConfig(): WritableMap? {
return MxConfiguration(reactApplicationContext).getConstants()
}
override fun otaDownload(
config: ReadableMap,
promise: Promise
) {
NativeOtaModule(reactApplicationContext).download(config, promise)
}
override fun otaDeploy(
config: ReadableMap,
promise: Promise
) {
NativeOtaModule(reactApplicationContext).deploy(config, promise)
}
override fun fsSetEncryptionEnabled(enabled: Boolean) {
NativeFsModule(reactApplicationContext).setEncryptionEnabled(enabled)
}
override fun fsSave(
blob: ReadableMap,
filePath: String,
promise: Promise
) {
NativeFsModule(reactApplicationContext).save(blob, filePath, promise)
}
override fun fsRead(filePath: String, promise: Promise) {
NativeFsModule(reactApplicationContext).read(filePath, promise)
}
override fun fsMove(
filePath: String,
newPath: String,
promise: Promise
) {
NativeFsModule(reactApplicationContext).move(filePath, newPath, promise)
}
override fun fsRemove(filePath: String, promise: Promise) {
NativeFsModule(reactApplicationContext).remove(filePath, promise)
}
override fun fsList(dirPath: String, promise: Promise) {
NativeFsModule(reactApplicationContext).list(dirPath, promise)
}
override fun fsReadAsDataURL(
filePath: String,
promise: Promise
) {
NativeFsModule(reactApplicationContext).readAsDataURL(filePath, promise)
}
override fun fsReadAsText(filePath: String, promise: Promise) {
NativeFsModule(reactApplicationContext).readAsText(filePath, promise)
}
override fun fsFileExists(filePath: String, promise: Promise) {
NativeFsModule(reactApplicationContext).fileExists(filePath, promise)
}
override fun fsWriteJson(
data: ReadableMap,
filepath: String,
promise: Promise
) {
NativeFsModule(reactApplicationContext).writeJson(data, filepath, promise)
}
override fun fsReadJson(filepath: String, promise: Promise) {
NativeFsModule(reactApplicationContext).readJson(filepath, promise)
}
override fun fsConstants(): WritableMap? {
return NativeFsModule(reactApplicationContext).getConstants()
}
override fun errorHandlerHandle(message: String, stackTrace: ReadableArray) {
NativeErrorHandler(reactApplicationContext).handle(message, stackTrace)
}
override fun navigationModeIsNavigationBarActive(): Boolean {
return NavigationModeModule(reactApplicationContext).isNavigationBarActive()
}
override fun navigationModeGetNavigationBarHeight(): Double {
return NavigationModeModule(reactApplicationContext).getNavigationBarHeight()
}
companion object {
const val NAME = "MendixNative"
}
}