Skip to content

Commit d717aa2

Browse files
Merge pull request #229 from mendix/mx-native-revamp
Update Mendix-native
2 parents 50ad3d3 + 4c65a9c commit d717aa2

12 files changed

Lines changed: 55 additions & 45 deletions

File tree

android/app/src/production/java/com/mendix/developerapp/MainActivity.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import android.os.Build
77
import android.os.Bundle
88
import android.util.Log
99
import android.view.KeyEvent
10-
import android.view.MotionEvent
1110
import android.view.View
1211
import android.view.WindowManager
1312
import android.widget.Toast
@@ -29,7 +28,6 @@ import com.mendix.developerapp.firebase.FCMNotificationHandler
2928
import com.mendix.developerapp.firebase.MENDIX_AD_CAMPAIGN_CHANNEL
3029
import com.mendix.developerapp.home.HomeViewModel
3130
import com.mendix.developerapp.mendixapp.MendixProjectFragment
32-
import com.mendix.developerapp.utilities.GlobalTouchEventListener
3331
import com.mendix.developerapp.utilities.getWarningFilterValue
3432
import com.mendix.developerapp.utilities.supportsAR
3533
import com.mendix.mendixnative.fragment.BackButtonHandler
@@ -209,12 +207,6 @@ class MainActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler, LaunchS
209207
})
210208
}
211209

212-
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
213-
return if ((currentFragment as? GlobalTouchEventListener)?.dispatchTouchEvent(ev) == true) {
214-
true
215-
} else super.dispatchTouchEvent(ev)
216-
}
217-
218210
override fun onBackPressed() {
219211
if ((currentFragment as? BackButtonHandler)?.onBackPressed() != true) {
220212
super.onBackPressed()

android/app/src/production/java/com/mendix/developerapp/MainApplication.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.mendix.developerapp
22

3+
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener
4+
import com.mendix.developerapp.loading.BundleDownloadListenerHolder
35
import com.mendix.developerapp.sampelapps.SampleAppsManager
46
import com.mendix.developerapp.splashscreen.SplashScreenPresenter
57
import com.mendix.developerapp.util.imageBackground
@@ -16,6 +18,11 @@ class MainApplication : BaseApplication() {
1618
var splashImagePath = splashBackground(backgroundImage)
1719
}
1820

21+
val bundleDownloadListenerHolder = BundleDownloadListenerHolder()
22+
23+
override val devBundleDownloadListener: DevBundleDownloadListener
24+
get() = bundleDownloadListenerHolder
25+
1926
override fun getUseDeveloperSupport(): Boolean {
2027
return SampleAppsManager.sampleAppJSBundlePath == null
2128
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.mendix.developerapp.loading
2+
3+
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener
4+
5+
/**
6+
* A delegating [DevBundleDownloadListener] that forwards calls to a mutable [delegate].
7+
*
8+
* This holder is set at ReactHost creation time (Application init). The actual delegate
9+
* is wired up later when the Fragment/ViewModel is created, and cleared on destroy.
10+
*/
11+
class BundleDownloadListenerHolder : DevBundleDownloadListener {
12+
var delegate: DevBundleDownloadListener? = null
13+
14+
override fun onSuccess() {
15+
delegate?.onSuccess()
16+
}
17+
18+
override fun onProgress(status: String?, done: Int?, total: Int?) {
19+
delegate?.onProgress(status, done, total)
20+
}
21+
22+
override fun onFailure(cause: Exception) {
23+
delegate?.onFailure(cause)
24+
}
25+
}

android/app/src/production/java/com/mendix/developerapp/mendixapp/MendixProjectFragment.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package com.mendix.developerapp.mendixapp
22

33
import android.os.Bundle
44
import androidx.navigation.fragment.findNavController
5-
import com.facebook.react.devsupport.DefaultDevLoadingViewImplementation
6-
import com.facebook.react.devsupport.setBundleDownloadListener
5+
import com.mendix.developerapp.MainApplication
76
import com.mendix.mendixnative.react.MxConfiguration
87

98
class MendixProjectFragment : MendixProjectFragmentBase() {
@@ -19,11 +18,16 @@ class MendixProjectFragment : MendixProjectFragmentBase() {
1918

2019
super.onCreate(savedInstanceState)
2120

22-
// Setting up our download listener
23-
setBundleDownloadListener(reactHost?.devSupportManager, viewModel.devServerCallback)
21+
// Wire the ViewModel's download listener into the application-level holder.
22+
// The holder was injected into the DevSupportManager at ReactHost creation time.
23+
(requireActivity().application as MainApplication)
24+
.bundleDownloadListenerHolder.delegate = viewModel.devServerCallback
25+
}
2426

25-
// This now uses built-in RN mechanism to show bundling progress.
26-
DefaultDevLoadingViewImplementation.setDevLoadingEnabled(true);
27+
override fun onDestroy() {
28+
(requireActivity().application as? MainApplication)
29+
?.bundleDownloadListenerHolder?.delegate = null
30+
super.onDestroy()
2731
}
2832

2933
override fun onCloseProjectSelected() {

android/app/src/production/java/com/mendix/developerapp/mendixapp/MendixProjectFragmentBase.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import android.widget.FrameLayout
88
import androidx.fragment.app.viewModels
99
import com.mendix.developerapp.MendixBaseFragment
1010
import com.mendix.developerapp.loading.ProjectLoaderViewModel
11-
import com.mendix.developerapp.utilities.GlobalTouchEventListener
1211
import com.zoontek.rnbootsplash.RNBootSplash
1312
import com.mendix.developerapp.R
1413

15-
open class MendixProjectFragmentBase : MendixBaseFragment(), GlobalTouchEventListener {
14+
open class MendixProjectFragmentBase : MendixBaseFragment() {
1615
protected val viewModel: ProjectLoaderViewModel by viewModels()
1716

1817
override fun onCreateView(

ios/DeveloperApp/AppDelegate.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@ import UIKit
22
import Firebase
33
import GoogleMaps
44
import UserNotifications
5-
import React_RCTAppDelegate
6-
import ReactAppDependencyProvider
75
import MendixNative
8-
import React
96

10-
@UIApplicationMain
7+
@main
118
class AppDelegate: ReactAppProvider {
129

1310
var shouldLaunchLastApp: Bool = false
1411
var previewingSampleApp: Bool = false
1512

1613
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1714
SessionCookieStore.restore() //iOS does not persist session cookies across app restarts, this helps persisting session cookies to match behaviour with Android
18-
setUpProvider(dependencyProvider: RCTAppDependencyProvider())
15+
setUpProvider()
1916
clearKeychainIfNecessary()
2017
setUpDevice()
2118
setUpGoogleMaps()
@@ -72,7 +69,7 @@ extension AppDelegate {
7269
//RootView
7370
extension AppDelegate {
7471
private func updateRootViewController(_ storyboard: UIStoryboard) {
75-
window = MendixReactWindow(frame: UIScreen.main.bounds)
72+
window = UIWindow(frame: UIScreen.main.bounds)
7673
window?.rootViewController = storyboard.instantiateInitialViewController()
7774
window?.makeKeyAndVisible()
7875
window?.overrideUserInterfaceStyle = .light // Force Light Mode

ios/DeveloperApp/Extension/MendixReactWindow+Extension.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

ios/DeveloperApp/MendixApp/MendixAppViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import UIKit
22
import MendixNative
3-
import React_RCTAppDelegate
43

5-
class MendixAppViewController: UIViewController, ReactNativeDelegate {
4+
class MendixAppViewController: UIViewController, ReactNativeDelegateInternal {
65
override func becomeFirstResponder() -> Bool {
76
return true
87
}

ios/Podfile.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ PODS:
195195
- React-renderercss
196196
- React-rendererdebug
197197
- React-utils
198+
- ReactAppDependencyProvider
198199
- ReactCodegen
199200
- ReactCommon/turbomodule/bridging
200201
- ReactCommon/turbomodule/core
@@ -4239,24 +4240,24 @@ SPEC CHECKSUMS:
42394240
FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d
42404241
FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc
42414242
fmt: 530618a01105dae0fa3a2f27c81ae11fa8f67eac
4242-
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
4243+
glog: e56ede4028c4b7418e6b1195a36b1656bb35e225
42434244
Google-Maps-iOS-Utils: 66d6de12be1ce6d3742a54661e7a79cb317a9321
42444245
GoogleAppMeasurement: f65fc137531af9ad647f1c0a42f3b6a4d3a98049
42454246
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
42464247
GoogleMaps: 8939898920281c649150e0af74aa291c60f2e77d
42474248
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
4248-
hermes-engine: 166613ab57f3dde1bf3f24c60212b66a1d585f8b
4249+
hermes-engine: 9f6d216d03a4100ed243774d56948a93afc5bae1
42494250
IQKeyboardManager: c8665b3396bd0b79402b4c573eac345a31c7d485
42504251
libwebp: 02b23773aedb6ff1fd38cec7a77b81414c6842a8
4251-
MendixNative: 91822aad01e73d9afe13953415824bd451b809d9
4252+
MendixNative: d2d164b7e500184fe8e8eedf101264f77cd43a0e
42524253
MultiplatformBleAdapter: b1fddd0d499b96b607e00f0faa8e60648343dc1d
42534254
nanopb: 438bc412db1928dac798aa6fd75726007be04262
42544255
op-sqlite: 64000c0da2357c4d73faf4d23ff34dd1ddb332d4
42554256
OpenSSL-Universal: 9110d21982bb7e8b22a962b6db56a8aa805afde7
42564257
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
42574258
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
42584259
QRCodeReader.swift: 373a389fe9a22d513c879a32a6f647c58f4ef572
4259-
RCT-Folly: b29feb752b08042c62badaef7d453f3bb5e6ae23
4260+
RCT-Folly: 36c4f904fb6cd0219dcb76b94e9502d2a72fab0b
42604261
RCTDeprecation: 7489702d717ceea80e271eeacb3fbca39fa3c056
42614262
RCTRequired: 1cceac389e77dc5826c681cb782d864b0ed623fc
42624263
RCTSwiftUI: afc0a0a635860da1040a0b894bfd529da06d7810

package-0.4.1.tgz

-2.23 MB
Binary file not shown.

0 commit comments

Comments
 (0)