Commit bdcc488e authored by justin's avatar justin

Merge branch 'master' into v1.12.13-hotfixes

# Conflicts:
#	android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
parents d39285ad 698e6a73
......@@ -22,7 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
......
......@@ -5,17 +5,18 @@ import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Debug;
import androidx.annotation.NonNull;
import com.idlefish.flutterboost.interfaces.*;
import io.flutter.embedding.android.FlutterView;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterJNI;
import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.embedding.engine.dart.DartExecutor;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.embedding.engine.loader.FlutterLoader;
import io.flutter.view.FlutterMain;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
......@@ -320,12 +321,24 @@ public class FlutterBoost {
FlutterMain.ensureInitializationComplete(
mPlatform.getApplication().getApplicationContext(), flutterShellArgs.toArray());
mEngine = new FlutterEngine(mPlatform.getApplication().getApplicationContext());
mEngine = new FlutterEngine(mPlatform.getApplication().getApplicationContext(),FlutterLoader.getInstance(),new FlutterJNI(),null,false);
registerPlugins(mEngine);
}
return mEngine;
}
private void registerPlugins(FlutterEngine engine) {
try {
Class<?> generatedPluginRegistrant = Class.forName("io.flutter.plugins.GeneratedPluginRegistrant");
Method registrationMethod = generatedPluginRegistrant.getDeclaredMethod("registerWith", FlutterEngine.class);
registrationMethod.invoke(null, engine);
} catch (Exception e) {
Debuger.exception(e);
}
}
public FlutterEngine engineProvider() {
return mEngine;
}
......
......@@ -21,6 +21,7 @@ import android.view.*;
import android.widget.*;
import com.idlefish.flutterboost.FlutterBoost;
import com.idlefish.flutterboost.XFlutterView;
import com.idlefish.flutterboost.XPlatformPlugin;
import io.flutter.Log;
import io.flutter.embedding.android.DrawableSplashScreen;
import io.flutter.embedding.android.FlutterView;
......@@ -439,12 +440,8 @@ public class BoostFlutterActivity extends Activity
@Nullable
@Override
public PlatformPlugin providePlatformPlugin(@Nullable Activity activity, @NonNull FlutterEngine flutterEngine) {
if (activity != null) {
return new PlatformPlugin(getActivity(), flutterEngine.getPlatformChannel());
} else {
return null;
}
public XPlatformPlugin providePlatformPlugin( @NonNull FlutterEngine flutterEngine) {
return new XPlatformPlugin( flutterEngine.getPlatformChannel());
}
/**
......
......@@ -23,6 +23,7 @@ import java.util.Map;
import com.idlefish.flutterboost.FlutterBoost;
import com.idlefish.flutterboost.Utils;
import com.idlefish.flutterboost.XFlutterView;
import com.idlefish.flutterboost.XPlatformPlugin;
import com.idlefish.flutterboost.interfaces.IFlutterViewContainer;
import com.idlefish.flutterboost.interfaces.IOperateSyncer;
import io.flutter.Log;
......@@ -30,6 +31,7 @@ import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.*;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.embedding.engine.plugins.activity.ActivityControlSurface;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.platform.PlatformPlugin;
......@@ -39,7 +41,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
private static final String TAG = "FlutterActivityAndFragmentDelegate";
private static int ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE=0;
@NonNull
private Host host;
@Nullable
......@@ -49,7 +51,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
@Nullable
private XFlutterView flutterView;
@Nullable
private PlatformPlugin platformPlugin;
private XPlatformPlugin platformPlugin;
private boolean isFlutterEngineFromHost;
......@@ -95,7 +97,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
// TODO(mattcarroll): the PlatformPlugin needs to be reimagined because it implicitly takes
// control of the entire window. This is unacceptable for non-fullscreen
// use-cases.
platformPlugin = host.providePlatformPlugin(host.getActivity(), flutterEngine);
platformPlugin = host.providePlatformPlugin(flutterEngine);
host.configureFlutterEngine(flutterEngine);
......@@ -129,13 +131,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
Log.v(TAG, "Creating FlutterView.");
flutterEngine.getActivityControlSurface().attachToActivity(
host.getActivity(),
host.getLifecycle()
);
mSyncer = FlutterBoost.instance().containerManager().generateSyncer(this);
ensureAlive();
......@@ -176,13 +171,19 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
Log.v(TAG, "onResume()");
ensureAlive();
flutterEngine.getLifecycleChannel().appIsResumed();
flutterEngine.getActivityControlSurface().attachToActivity(
host.getActivity(),
host.getLifecycle()
);
if(ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE==0||
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE!=this.host.getActivity().hashCode()){
flutterEngine.getActivityControlSurface().detachFromActivityForConfigChanges();
flutterEngine.getActivityControlSurface().attachToActivity(
host.getActivity(),
host.getLifecycle()
);
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE=this.host.getActivity().hashCode();
}
if(platformPlugin!=null)
platformPlugin.attachToActivity( host.getActivity());
}
......@@ -191,7 +192,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
public void onPostResume() {
Log.v(TAG, "onPostResume()");
ensureAlive();
// Utils.setStatusBarLightMode(host.getActivity(), true);
}
......@@ -230,10 +230,15 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
// Null out the platformPlugin to avoid a possible retain cycle between the plugin, this Fragment,
// and this Fragment's Activity.
if (platformPlugin != null) {
// platformPlugin.destroy();
platformPlugin.detachActivity();
platformPlugin = null;
}
if(ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE!=0||
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE==this.host.getActivity().hashCode()){
flutterEngine.getActivityControlSurface().detachFromActivityForConfigChanges();
}
Utils.fixInputMethodManagerLeak(host.getActivity());
}
......@@ -461,7 +466,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
* Flutter experience should control system chrome.
*/
@Nullable
PlatformPlugin providePlatformPlugin(@Nullable Activity activity, @NonNull FlutterEngine flutterEngine);
XPlatformPlugin providePlatformPlugin( @NonNull FlutterEngine flutterEngine);
/**
* Hook for the host to configure the {@link FlutterEngine} as desired.
......
......@@ -16,6 +16,7 @@ import androidx.fragment.app.FragmentActivity;
import com.idlefish.flutterboost.FlutterBoost;
import com.idlefish.flutterboost.Utils;
import com.idlefish.flutterboost.XFlutterView;
import com.idlefish.flutterboost.XPlatformPlugin;
import io.flutter.embedding.android.*;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterShellArgs;
......@@ -467,12 +468,9 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
@Nullable
@Override
public PlatformPlugin providePlatformPlugin(@Nullable Activity activity, @NonNull FlutterEngine flutterEngine) {
if (activity != null) {
return new PlatformPlugin(getActivity(), flutterEngine.getPlatformChannel());
} else {
return null;
}
public XPlatformPlugin providePlatformPlugin( @NonNull FlutterEngine flutterEngine) {
return new XPlatformPlugin(flutterEngine.getPlatformChannel());
}
/**
......
......@@ -446,7 +446,7 @@ class _FlutterRouteWidgetState extends State<FlutterRouteWidget> {
///后面的参数会在native的IPlatform.startActivity方法回调中拼接到url的query部分。
///例如:sample://nativePage?aaa=bbb
onTap: () => FlutterBoost.singleton
.open("sample://flutterPage", urlParams:<dynamic,dynamic> {
.open("sample://flutterPage", urlParams:<String,dynamic> {
"query": {"aaa": "bbb"}
}),
),
......
name: flutter_boost
description: A next-generation Flutter-Native hybrid solution. FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts.
version: 1.12.13
version: 1.12.13+1
author: Alibaba Xianyu
homepage: https://github.com/alibaba/flutter_boost
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment