-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ability to embed into platform host projects #1799
Open
vmutafov
wants to merge
6
commits into
NativeScript:main
Choose a base branch
from
vmutafov:embed
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+740
−66
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
496fcbb
feat: support android embedding
vmutafov 5015a54
fix: remove NativeScriptActivity and NativeScriptApplication from git…
vmutafov 62427bc
fix: use TestNativeScriptActivity and TestNativeScriptApplication whe…
vmutafov 1cf7105
chore: re-add the runtime dependencies
edusperoni 34eaae5
feat: remove deprecations and update error activity layout
edusperoni be29f1e
fix: fix missing colors
edusperoni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test-app/build-tools/static-binding-generator/src/main/resources/js_parser.js
Large diffs are not rendered by default.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
test-app/build-tools/static-binding-generator/src/main/resources/livesync.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (global.__onLiveSync) { | ||
global.__onLiveSync(); | ||
} |
175 changes: 175 additions & 0 deletions
175
test-app/build-tools/static-binding-generator/src/main/resources/ts_helpers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
(function () { | ||
|
||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length; | ||
var r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
|
||
if (typeof global.Reflect === "object" && typeof global.Reflect.decorate === "function") { | ||
r = global.Reflect.decorate(decorators, target, key, desc); | ||
} | ||
else { | ||
for (var i = decorators.length - 1; i >= 0; i--) { | ||
if (d = decorators[i]) { | ||
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
} | ||
} | ||
} | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
|
||
// For backward compatibility. | ||
var __native = function (thiz) { | ||
// we are setting the __container__ property to the base class when the super method is called | ||
// if the constructor returns the __native(this) call we will use the old implementation | ||
// copying all the properties to the result | ||
// otherwise if we are using the result from the super() method call we won't need such logic | ||
// as thiz already contains the parent properties | ||
// this way we now support both implementations in typescript generated constructors: | ||
// 1: super(); return __native(this); | ||
// 2: return super() || this; | ||
if (thiz.__container__) { | ||
var result = thiz.__proto__; | ||
|
||
for (var prop in thiz) { | ||
if (thiz.hasOwnProperty(prop)) { | ||
thiz.__proto__[prop] = thiz[prop]; | ||
delete thiz[prop]; | ||
} | ||
} | ||
|
||
thiz.constructor = undefined; | ||
thiz.__proto__ = undefined; | ||
Object.freeze(thiz); | ||
Object.preventExtensions(thiz); | ||
return result; | ||
} else { | ||
return thiz; | ||
} | ||
}; | ||
|
||
var __extends = function (Child, Parent) { | ||
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1); | ||
if (!extendNativeClass) { | ||
__extends_ts(Child, Parent); | ||
return; | ||
} | ||
if (Parent.__isPrototypeImplementationObject) { | ||
throw new Error("Can not extend an already extended native object."); | ||
} | ||
|
||
function extend(thiz) { | ||
var child = thiz.__proto__.__child; | ||
if (!child.__extended) { | ||
var parent = thiz.__proto__.__parent; | ||
child.__extended = parent.extend(child.name, child.prototype, true); | ||
// This will deal with "i instanceof child" | ||
child[Symbol.hasInstance] = function (instance) { | ||
return instance instanceof this.__extended; | ||
} | ||
} | ||
return child.__extended; | ||
}; | ||
|
||
Parent.__activityExtend = function (parent, name, implementationObject) { | ||
__log("__activityExtend called"); | ||
return parent.extend(name, implementationObject); | ||
}; | ||
|
||
Parent.call = function (thiz) { | ||
var Extended = extend(thiz); | ||
thiz.__container__ = true; | ||
if (arguments.length > 1) { | ||
thiz.__proto__ = new (Function.prototype.bind.apply(Extended, [null].concat(Array.prototype.slice.call(arguments, 1)))); | ||
} | ||
else { | ||
thiz.__proto__ = new Extended() | ||
} | ||
return thiz.__proto__; | ||
}; | ||
|
||
Parent.apply = function (thiz, args) { | ||
var Extended = extend(thiz); | ||
thiz.__container__ = true; | ||
if (args && args.length > 0) { | ||
thiz.__proto__ = new (Function.prototype.bind.apply(Extended, [null].concat(args))); | ||
} | ||
else { | ||
thiz.__proto__ = new Extended(); | ||
} | ||
return thiz.__proto__; | ||
}; | ||
__extends_ns(Child, Parent); | ||
Child.__isPrototypeImplementationObject = true; | ||
Child.__proto__ = Parent; | ||
Child.prototype.__parent = Parent; | ||
Child.prototype.__child = Child; | ||
} | ||
|
||
var __extends_ts = function (child, parent) { | ||
extendStaticFunctions(child, parent); | ||
assignPrototypeFromParentToChild(parent, child); | ||
}; | ||
|
||
var __extends_ns = function (child, parent) { | ||
if (!parent.extend) { | ||
assignPropertiesFromParentToChild(parent, child); | ||
} | ||
|
||
assignPrototypeFromParentToChild(parent, child); | ||
}; | ||
|
||
var extendStaticFunctions = | ||
Object.setPrototypeOf | ||
|| (hasInternalProtoProperty() && function (child, parent) { child.__proto__ = parent; }) | ||
|| assignPropertiesFromParentToChild; | ||
|
||
function hasInternalProtoProperty() { | ||
return { __proto__: [] } instanceof Array; | ||
} | ||
|
||
function assignPropertiesFromParentToChild(parent, child) { | ||
for (var property in parent) { | ||
if (parent.hasOwnProperty(property)) { | ||
child[property] = parent[property]; | ||
} | ||
} | ||
} | ||
|
||
function assignPrototypeFromParentToChild(parent, child) { | ||
function __() { | ||
this.constructor = child; | ||
} | ||
|
||
if (parent === null) { | ||
child.prototype = Object.create(null); | ||
} else { | ||
__.prototype = parent.prototype; | ||
child.prototype = new __(); | ||
} | ||
} | ||
|
||
|
||
function JavaProxy(className) { | ||
return function (target) { | ||
var extended = target.extend(className, target.prototype) | ||
extended.name = className; | ||
return extended; | ||
}; | ||
} | ||
|
||
function Interfaces(interfacesArr) { | ||
return function (target) { | ||
if (interfacesArr instanceof Array) { | ||
// attach interfaces: [] to the object | ||
target.prototype.interfaces = interfacesArr; | ||
} | ||
} | ||
} | ||
|
||
Object.defineProperty(global, "__native", { value: __native }); | ||
Object.defineProperty(global, "__extends", { value: __extends }); | ||
Object.defineProperty(global, "__decorate", { value: __decorate }); | ||
|
||
global.JavaProxy = JavaProxy; | ||
global.Interfaces = Interfaces; | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../src/test/resources/org/nativescript/staticbindinggenerator/test/datarow-named-extend.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
java.lang.Object*****toString*com.tns.NativeScriptActivity*MyActivity.js* | ||
java.lang.Object*****toString*com.tns.TestNativeScriptActivity*MyActivity.js* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="#44403c" /> | ||
<corners android:bottomRightRadius="8dp" | ||
android:bottomLeftRadius="8dp" | ||
android:topRightRadius="8dp" | ||
android:topLeftRadius="8dp"/> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="@color/nativescript_blue" /> | ||
<corners android:bottomRightRadius="8dp" | ||
android:bottomLeftRadius="8dp" | ||
android:topRightRadius="8dp" | ||
android:topLeftRadius="8dp"/> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="nativescript_blue">#65ADF1</color> | ||
<color name="gray">#1c1917</color> | ||
<color name="red">#dc2626</color> | ||
<color name="white">#ffffff</color> | ||
</resources> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
test-app/runtime/src/main/java/com/tns/NativeScriptActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.tns; | ||
|
||
public class NativeScriptActivity extends org.nativescript.NativeScriptActivity { | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test-app/runtime/src/main/java/com/tns/embedding/ApplicationHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.tns.embedding; | ||
|
||
import android.app.Application; | ||
|
||
public class ApplicationHolder { | ||
|
||
private static Application application; | ||
|
||
private ApplicationHolder() { | ||
|
||
} | ||
|
||
public static void setInstance(Application application) { | ||
ApplicationHolder.application = application; | ||
} | ||
|
||
public static Application getInstance() { | ||
return application; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
test-app/runtime/src/main/java/com/tns/embedding/CallbacksStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.tns.embedding; | ||
|
||
public class CallbacksStore { | ||
|
||
private static EmbeddableFragmentCallbacks fragmentCallbacks; | ||
private static EmbeddableActivityCallbacks activityCallbacks; | ||
|
||
public static void setFragmentCallbacks(EmbeddableFragmentCallbacks callbacks) { | ||
fragmentCallbacks = callbacks; | ||
} | ||
|
||
public static void setActivityCallbacks(EmbeddableActivityCallbacks callbacks) { | ||
activityCallbacks = callbacks; | ||
} | ||
|
||
public static EmbeddableFragmentCallbacks getFragmentCallbacks() { | ||
if (fragmentCallbacks == null) { | ||
throw new RuntimeException("{N} Core modules: Fragment callbacks are null"); | ||
} | ||
return fragmentCallbacks; | ||
} | ||
|
||
public static EmbeddableActivityCallbacks getActivityCallbacks() { | ||
if (activityCallbacks == null) { | ||
throw new RuntimeException("{N} Core modules: Activity callbacks are null"); | ||
} | ||
return activityCallbacks; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
test-app/runtime/src/main/java/com/tns/embedding/EmbeddableActivityCallbacks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.tns.embedding; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
public abstract class EmbeddableActivityCallbacks { | ||
|
||
private AppCompatActivity activity; | ||
|
||
public void setActivity(AppCompatActivity activity) { | ||
this.activity = activity; | ||
} | ||
|
||
public AppCompatActivity getActivity() { | ||
return this.activity; | ||
} | ||
|
||
public abstract void onPostResume(); | ||
|
||
public abstract void onStart(); | ||
|
||
public abstract void onStop(); | ||
|
||
public abstract void onDestroy(); | ||
|
||
public abstract void onActivityResult(int param_0, int param_1, android.content.Intent param_2); | ||
|
||
public abstract void onCreate(android.os.Bundle param_0); | ||
|
||
public abstract void onRequestPermissionsResult(int param_0, java.lang.String[] param_1, int[] param_2); | ||
|
||
public abstract void onSaveInstanceState(android.os.Bundle param_0); | ||
|
||
public abstract void onBackPressed(); | ||
|
||
public abstract void onNewIntent(android.content.Intent param_0); | ||
|
||
public abstract void onCreate(android.os.Bundle param_0, android.os.PersistableBundle param_1); | ||
|
||
public abstract void onSaveInstanceState(android.os.Bundle param_0, android.os.PersistableBundle param_1); | ||
} |
31 changes: 31 additions & 0 deletions
31
test-app/runtime/src/main/java/com/tns/embedding/EmbeddableFragmentCallbacks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.tns.embedding; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.fragment.app.Fragment; | ||
|
||
public abstract class EmbeddableFragmentCallbacks { | ||
|
||
private Fragment fragment; | ||
|
||
public void setFragment(Fragment fragment) { | ||
this.fragment = fragment; | ||
} | ||
|
||
public Fragment getFragment() { | ||
return fragment; | ||
} | ||
|
||
public abstract View onCreateView( | ||
LayoutInflater inflater, | ||
ViewGroup container, | ||
Bundle savedInstanceState | ||
); | ||
|
||
public abstract void onResume(); | ||
|
||
public abstract void onPause(); | ||
} |
13 changes: 13 additions & 0 deletions
13
test-app/runtime/src/main/java/com/tns/embedding/JetpackNavigationUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.tns.embedding; | ||
|
||
import android.view.View; | ||
|
||
import androidx.navigation.NavController; | ||
import androidx.navigation.Navigation; | ||
|
||
public class JetpackNavigationUtils { | ||
public static void navigate(View view, String route) { | ||
NavController nav = Navigation.findNavController(view); | ||
nav.navigate(route); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
public interface Plugin { | ||
boolean execute(android.content.Context context) throws Exception; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
test-app/runtime/src/main/java/org/nativescript/Bootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.nativescript; | ||
|
||
import android.app.Application; | ||
|
||
import com.tns.ManualInstrumentation; | ||
import com.tns.RuntimeHelper; | ||
import com.tns.embedding.ApplicationHolder; | ||
|
||
public class Bootstrap { | ||
public static void bootstrapNativeScriptRuntime(Application application) { | ||
ManualInstrumentation.Frame frame = ManualInstrumentation.start("NativeScriptApplication.onCreate"); | ||
try { | ||
ApplicationHolder.setInstance(application); | ||
com.tns.Runtime runtime = RuntimeHelper.initRuntime(application); | ||
if (runtime != null) { | ||
runtime.run(); | ||
} | ||
} finally { | ||
frame.close(); | ||
} | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
test-app/runtime/src/main/java/org/nativescript/NativeScriptActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package org.nativescript; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.tns.embedding.CallbacksStore; | ||
import com.tns.embedding.EmbeddableActivityCallbacks; | ||
|
||
import org.nativescript.android.runtime.R; | ||
|
||
public class NativeScriptActivity extends AppCompatActivity { | ||
|
||
private final EmbeddableActivityCallbacks callbacks = CallbacksStore.getActivityCallbacks(); | ||
static View nativeScriptView = null; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
callbacks.setActivity(this); | ||
callbacks.onCreate(savedInstanceState); | ||
// drawNativeScriptApp(savedInstanceState); | ||
} | ||
|
||
@Override | ||
public void onCreate(android.os.Bundle savedInstanceState, android.os.PersistableBundle persistableBundle) { | ||
super.onCreate(savedInstanceState, persistableBundle); | ||
callbacks.setActivity(this); | ||
callbacks.onCreate(savedInstanceState, persistableBundle); | ||
// drawNativeScriptApp(savedInstanceState); | ||
} | ||
|
||
private void drawNativeScriptApp(Bundle savedInstanceState) { | ||
setContentView(R.layout.main); | ||
if (savedInstanceState == null) { | ||
getSupportFragmentManager().beginTransaction() | ||
.replace(R.id.container, new NativeScriptFragment()) | ||
.commitNow(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onPostResume() { | ||
super.onPostResume(); | ||
callbacks.onPostResume(); | ||
} | ||
|
||
@Override | ||
protected void onStart() { | ||
super.onStart(); | ||
callbacks.onStart(); | ||
} | ||
|
||
@Override | ||
protected void onStop() { | ||
super.onStop(); | ||
callbacks.onStop(); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
try { | ||
callbacks.onDestroy(); | ||
nativeScriptView = null; | ||
} finally { | ||
super.onDestroy(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int param_0, int param_1, android.content.Intent param_2) { | ||
super.onActivityResult(param_0, param_1, param_2); | ||
callbacks.onActivityResult(param_0, param_1, param_2); | ||
} | ||
|
||
@SuppressLint("MissingSuperCall") | ||
@Override | ||
public void onRequestPermissionsResult(int param_0, java.lang.String[] param_1, int[] param_2) { | ||
callbacks.onRequestPermissionsResult(param_0, param_1, param_2); | ||
} | ||
|
||
@Override | ||
protected void onSaveInstanceState(android.os.Bundle param_0) { | ||
super.onSaveInstanceState(param_0); | ||
callbacks.onSaveInstanceState(param_0); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
callbacks.onBackPressed(); | ||
} | ||
|
||
@Override | ||
protected void onNewIntent(android.content.Intent param_0) { | ||
super.onNewIntent(param_0); | ||
super.setIntent(param_0); | ||
callbacks.onNewIntent(param_0); | ||
} | ||
|
||
@Override | ||
public void onSaveInstanceState(android.os.Bundle param_0, android.os.PersistableBundle param_1) { | ||
super.onSaveInstanceState(param_0, param_1); | ||
} | ||
|
||
public void superOnBackPressed() { | ||
super.onBackPressed(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
test-app/runtime/src/main/java/org/nativescript/NativeScriptApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.nativescript; | ||
|
||
import static org.nativescript.Bootstrap.bootstrapNativeScriptRuntime; | ||
|
||
import android.app.Application; | ||
|
||
public class NativeScriptApplication extends Application { | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
bootstrapNativeScriptRuntime(this); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
test-app/runtime/src/main/java/org/nativescript/NativeScriptFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.nativescript; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.fragment.app.Fragment; | ||
|
||
import com.tns.embedding.CallbacksStore; | ||
import com.tns.embedding.EmbeddableFragmentCallbacks; | ||
|
||
public class NativeScriptFragment extends Fragment { | ||
|
||
private final EmbeddableFragmentCallbacks callbacks = CallbacksStore.getFragmentCallbacks(); | ||
|
||
@Override | ||
public void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
callbacks.setFragment(this); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, | ||
@Nullable Bundle savedInstanceState) { | ||
if (NativeScriptActivity.nativeScriptView == null) { | ||
NativeScriptActivity.nativeScriptView = callbacks.onCreateView(inflater, container, savedInstanceState); | ||
} | ||
|
||
FrameLayout wrapper = new FrameLayout(requireContext()); | ||
wrapper.addView(NativeScriptActivity.nativeScriptView); | ||
return wrapper; | ||
} | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
callbacks.onResume(); | ||
} | ||
|
||
@Override | ||
public void onPause() { | ||
super.onPause(); | ||
callbacks.onPause(); | ||
} | ||
|
||
@Override | ||
public void onDestroyView() { | ||
super.onDestroyView(); | ||
if (NativeScriptActivity.nativeScriptView != null && NativeScriptActivity.nativeScriptView.getParent() != null) { | ||
((ViewGroup) NativeScriptActivity.nativeScriptView.getParent()).removeView(NativeScriptActivity.nativeScriptView); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/container" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" > | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these needed? It'd mean all apps now depend on material, androidx navigation and appcompat