File tree Expand file tree Collapse file tree 4 files changed +30
-26
lines changed
Expand file tree Collapse file tree 4 files changed +30
-26
lines changed Original file line number Diff line number Diff line change @@ -36,12 +36,8 @@ open class SwiftSupportAppCompatActivity: AndroidContextWrapper {
3636
3737 #if os(Android)
3838 // Ask app for main activity type.
39- let objectType = SwiftAndroidMainActivity ( )
40-
39+ let objectType = SwiftAndroidMainApplication ( ) . runtimeConfiguration. appCompatActivity
4140 let swiftObject = objectType. init ( javaObject: __this)
42-
43- //var locals = [jobject]()
44- //return swiftObject.localJavaObject( &locals )
4541 return swiftObject. swiftValue ( ) . j
4642 #else
4743 fatalError ( " Can only run on Android OS " )
@@ -722,12 +718,6 @@ fileprivate extension SwiftSupport.App.AppCompatActivity {
722718
723719// MARK: - Native Methods
724720
725- #if os(Android)
726- /// Needs to be implemented by app.
727- @_silgen_name ( " SwiftAndroidMainActivity " )
728- internal func SwiftAndroidMainActivity( ) -> SwiftSupportAppCompatActivity . Type
729- #endif
730-
731721@_silgen_name ( " Java_org_pureswift_swiftandroidsupport_app_SwiftAppCompatActivity_onCreateNative " )
732722public func SwiftSupportAppCompatActivity_onCreate( _ __env: UnsafeMutablePointer < JNIEnv ? > ,
733723 _ __this: jobject ? ,
Original file line number Diff line number Diff line change @@ -22,17 +22,17 @@ open class SwiftApplication: JavaObject {
2222 #if os(Android)
2323 // Ask app for main activity type.
2424 let objectType = SwiftAndroidMainApplication ( )
25-
2625 let swiftObject = objectType. init ( javaObject: __this)
27-
28- //var locals = [jobject]()
29- //return swiftObject.localJavaObject( &locals )
3026 return swiftObject. swiftValue ( ) . j
3127 #else
3228 fatalError ( " Can only run on Android OS " )
3329 #endif
3430 }
3531
32+ open class var runtimeConfiguration : RuntimeConfiguration {
33+ return RuntimeConfiguration . default
34+ }
35+
3636 open func onConfigurationChanged( newConfig: JavaObject ? ) {
3737
3838 NSLog ( " \( type ( of: self ) ) \( #function) " )
Original file line number Diff line number Diff line change @@ -23,12 +23,8 @@ open class SwiftComponentActivity: AndroidContextWrapper {
2323
2424 #if os(Android)
2525 // Ask app for main activity type.
26- let objectType = SwiftAndroidMainActivity ( )
27-
26+ let objectType = SwiftAndroidMainApplication ( ) . runtimeConfiguration. componentActivity
2827 let swiftObject = objectType. init ( javaObject: __this)
29-
30- //var locals = [jobject]()
31- //return swiftObject.localJavaObject( &locals )
3228 return swiftObject. swiftValue ( ) . j
3329 #else
3430 fatalError ( " Can only run on Android OS " )
@@ -709,12 +705,6 @@ fileprivate extension SwiftComponentActivity {
709705
710706// MARK: - Native Methods
711707
712- #if os(Android)
713- /// Needs to be implemented by app.
714- @_silgen_name ( " SwiftAndroidMainActivity " )
715- internal func SwiftAndroidMainActivity( ) -> SwiftComponentActivity . Type
716- #endif
717-
718708@_silgen_name ( " Java_org_pureswift_swiftandroidsupport_app_SwiftComponentActivity_onCreateNative " )
719709public func SwiftComponentActivity_onCreate( _ __env: UnsafeMutablePointer < JNIEnv ? > ,
720710 _ __this: jobject ? ,
Original file line number Diff line number Diff line change 1+ //
2+ // RuntimeConfiguration.swift
3+ //
4+ //
5+ // Created by Alsey Coleman Miller on 11/30/22.
6+ //
7+
8+ /// Swift Android runtime configuration
9+ public struct RuntimeConfiguration {
10+
11+ public var appCompatActivity : SwiftSupportAppCompatActivity . Type
12+
13+ public var componentActivity : SwiftComponentActivity . Type
14+ }
15+
16+ public extension RuntimeConfiguration {
17+
18+ static var `default` : RuntimeConfiguration {
19+ RuntimeConfiguration (
20+ appCompatActivity: SwiftSupportAppCompatActivity . self,
21+ componentActivity: SwiftComponentActivity . self
22+ )
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments