Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢冠章
flutter_boost_1.22.4
Commits
d9ac3683
Commit
d9ac3683
authored
Oct 09, 2019
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Boost 1.9升级
parent
570f4acb
Changes
32
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
2458 additions
and
228 deletions
+2458
-228
android/build.gradle
android/build.gradle
+6
-3
android/src/main/java/com/idlefish/flutterboost/BoostEngineProvider.java
...n/java/com/idlefish/flutterboost/BoostEngineProvider.java
+13
-12
android/src/main/java/com/idlefish/flutterboost/BoostFlutterEngine.java
...in/java/com/idlefish/flutterboost/BoostFlutterEngine.java
+95
-103
android/src/main/java/com/idlefish/flutterboost/BoostFlutterView.java
...main/java/com/idlefish/flutterboost/BoostFlutterView.java
+7
-6
android/src/main/java/com/idlefish/flutterboost/BoostPluginRegistry.java
...n/java/com/idlefish/flutterboost/BoostPluginRegistry.java
+141
-0
android/src/main/java/com/idlefish/flutterboost/ContainerRecord.java
.../main/java/com/idlefish/flutterboost/ContainerRecord.java
+50
-15
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
...src/main/java/com/idlefish/flutterboost/FlutterBoost.java
+12
-12
android/src/main/java/com/idlefish/flutterboost/FlutterBoostPlugin.java
...in/java/com/idlefish/flutterboost/FlutterBoostPlugin.java
+276
-0
android/src/main/java/com/idlefish/flutterboost/FlutterViewContainerManager.java
...om/idlefish/flutterboost/FlutterViewContainerManager.java
+4
-4
android/src/main/java/com/idlefish/flutterboost/NewFlutterBoost.java
.../main/java/com/idlefish/flutterboost/NewFlutterBoost.java
+209
-0
android/src/main/java/com/idlefish/flutterboost/StateListener.java
...rc/main/java/com/idlefish/flutterboost/StateListener.java
+1
-1
android/src/main/java/com/idlefish/flutterboost/XFlutterView.java
...src/main/java/com/idlefish/flutterboost/XFlutterView.java
+3
-3
android/src/main/java/com/idlefish/flutterboost/XTextInputPlugin.java
...main/java/com/idlefish/flutterboost/XTextInputPlugin.java
+8
-0
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterActivity.java
...dlefish/flutterboost/containers/BoostFlutterActivity.java
+6
-5
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterDefaultActivity.java
.../flutterboost/containers/BoostFlutterDefaultActivity.java
+5
-0
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterFragment.java
...dlefish/flutterboost/containers/BoostFlutterFragment.java
+6
-5
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
...rboost/containers/FlutterActivityAndFragmentDelegate.java
+596
-0
android/src/main/java/com/idlefish/flutterboost/containers/FlutterSplashView.java
...m/idlefish/flutterboost/containers/FlutterSplashView.java
+294
-0
android/src/main/java/com/idlefish/flutterboost/containers/NewBoostFlutterActivity.java
...fish/flutterboost/containers/NewBoostFlutterActivity.java
+615
-0
android/src/main/java/com/idlefish/flutterboost/interfaces/IFlutterEngineProvider.java
...efish/flutterboost/interfaces/IFlutterEngineProvider.java
+5
-3
android/src/main/java/com/idlefish/flutterboost/interfaces/IFlutterViewContainer.java
...lefish/flutterboost/interfaces/IFlutterViewContainer.java
+2
-1
android/src/main/java/com/idlefish/flutterboost/interfaces/INativeRouter.java
...a/com/idlefish/flutterboost/interfaces/INativeRouter.java
+13
-0
android/src/main/java/com/idlefish/flutterboost/interfaces/IStateListener.java
.../com/idlefish/flutterboost/interfaces/IStateListener.java
+2
-2
example/android/app/build.gradle
example/android/app/build.gradle
+5
-5
example/android/app/src/main/AndroidManifest.xml
example/android/app/src/main/AndroidManifest.xml
+15
-1
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterFragment.java
.../taobao/idlefish/flutterboostexample/FlutterFragment.java
+6
-0
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterPageActivity.java
...bao/idlefish/flutterboostexample/FlutterPageActivity.java
+6
-0
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
...om/taobao/idlefish/flutterboostexample/MyApplication.java
+49
-41
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/PageRouter.java
...a/com/taobao/idlefish/flutterboostexample/PageRouter.java
+4
-2
example/ios/Runner/GeneratedPluginRegistrant.m
example/ios/Runner/GeneratedPluginRegistrant.m
+2
-2
example/lib/main.dart
example/lib/main.dart
+1
-1
pubspec.yaml
pubspec.yaml
+1
-1
No files found.
android/build.gradle
View file @
d9ac3683
...
...
@@ -26,6 +26,7 @@ android {
buildToolsVersion
'27.0.3'
defaultConfig
{
minSdkVersion
16
targetSdkVersion
28
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
lintOptions
{
...
...
@@ -34,9 +35,11 @@ android {
}
dependencies
{
implementation
'com.alibaba:fastjson:1.2.41'
implementation
'com.android.support:support-v4:26.1.0'
implementation
'com.android.support:appcompat-v7:26.1.0'
implementation
'com.android.support:appcompat-v7:28.0.0'
implementation
'com.android.support:design:28.0.0'
implementation
'com.android.support:support-v4:28.0.0'
implementation
'android.arch.lifecycle:common-java8:1.1.1'
}
ext
{
...
...
android/src/main/java/com/idlefish/flutterboost/BoostEngineProvider.java
View file @
d9ac3683
...
...
@@ -28,12 +28,13 @@ import android.content.Context;
import
com.idlefish.flutterboost.interfaces.IFlutterEngineProvider
;
import
com.idlefish.flutterboost.interfaces.IStateListener
;
import
io.flutter.embedding.engine.FlutterEngine
;
import
io.flutter.embedding.engine.FlutterShellArgs
;
import
io.flutter.view.FlutterMain
;
public
class
BoostEngineProvider
implements
IFlutterEngineProvider
{
private
Boost
FlutterEngine
mEngine
=
null
;
private
FlutterEngine
mEngine
=
null
;
public
BoostEngineProvider
()
{}
...
...
@@ -43,7 +44,7 @@ public class BoostEngineProvider implements IFlutterEngineProvider {
}
@Override
public
Boost
FlutterEngine
provideEngine
(
Context
context
)
{
public
FlutterEngine
provideEngine
(
Context
context
)
{
Utils
.
assertCallOnMainThread
();
if
(
mEngine
==
null
)
{
...
...
@@ -51,25 +52,25 @@ public class BoostEngineProvider implements IFlutterEngineProvider {
FlutterMain
.
ensureInitializationComplete
(
context
.
getApplicationContext
(),
flutterShellArgs
.
toArray
());
mEngine
=
create
Engine
(
context
.
getApplicationContext
());
mEngine
=
new
Flutter
Engine
(
context
.
getApplicationContext
());
final
IStateListener
stateListener
=
FlutterBoost
.
sInstance
.
mStateListener
;
if
(
stateListener
!=
null
)
{
stateListener
.
onEngineCreated
(
mEngine
);
}
//
final IStateListener stateListener = FlutterBoost.sInstance.mStateListener;
//
if(stateListener != null) {
//
stateListener.onEngineCreated(mEngine);
//
}
}
return
mEngine
;
}
@Override
public
Boost
FlutterEngine
tryGetEngine
()
{
public
FlutterEngine
tryGetEngine
()
{
return
mEngine
;
}
public
static
void
assertEngineRunning
(){
final
BoostFlutterEngine
engine
=
FlutterBoost
.
singleton
().
engineProvider
().
tryGetEngine
();
if
(
engine
==
null
||
!
engine
.
isRunning
())
{
throw
new
RuntimeException
(
"engine is not running yet!"
);
}
final
FlutterEngine
engine
=
NewFlutterBoost
.
instance
().
engineProvider
().
tryGetEngine
();
//
if(engine == null || !engine.isRunning()) {
//
throw new RuntimeException("engine is not running yet!");
//
}
}
}
android/src/main/java/com/idlefish/flutterboost/BoostFlutterEngine.java
View file @
d9ac3683
...
...
@@ -30,122 +30,114 @@ import io.flutter.view.FlutterView;
import
io.flutter.view.TextureRegistry
;
public
class
BoostFlutterEngine
extends
FlutterEngine
{
protected
final
Context
mContext
;
protected
final
BoostPluginRegistry
mBoostPluginRegistry
;
protected
final
DartExecutor
.
DartEntrypoint
mEntrypoint
;
protected
final
String
mInitRoute
;
private
final
FakeRender
mFakeRender
;
protected
WeakReference
<
Activity
>
mCurrentActivityRef
;
public
BoostFlutterEngine
(
@NonNull
Context
context
)
{
this
(
context
,
null
,
null
);
}
public
BoostFlutterEngine
(
@NonNull
Context
context
,
DartExecutor
.
DartEntrypoint
entrypoint
,
String
initRoute
)
{
super
(
context
);
mContext
=
context
.
getApplicationContext
();
mBoostPluginRegistry
=
new
BoostPluginRegistry
(
this
,
context
);
if
(
entrypoint
!=
null
)
{
mEntrypoint
=
entrypoint
;
}
else
{
mEntrypoint
=
defaultDartEntrypoint
(
context
);
}
if
(
initRoute
!=
null
)
{
mInitRoute
=
initRoute
;
}
else
{
mInitRoute
=
defaultInitialRoute
(
context
);
}
FlutterJNI
flutterJNI
=
null
;
try
{
Field
field
=
FlutterEngine
.
class
.
getDeclaredField
(
"flutterJNI"
);
field
.
setAccessible
(
true
);
flutterJNI
=
(
FlutterJNI
)
field
.
get
(
this
);
}
catch
(
Throwable
t
)
{
try
{
for
(
Field
field:
FlutterEngine
.
class
.
getDeclaredFields
())
{
field
.
setAccessible
(
true
);
Object
o
=
field
.
get
(
this
);
if
(
o
instanceof
FlutterJNI
)
{
flutterJNI
=
(
FlutterJNI
)
o
;
}
}
if
(
flutterJNI
==
null
)
{
throw
new
RuntimeException
(
"FlutterJNI not found"
);
}
}
catch
(
Throwable
it
){
Debuger
.
exception
(
it
);
}
}
mFakeRender
=
new
FakeRender
(
flutterJNI
);
}
public
void
startRun
(
@Nullable
Activity
activity
)
{
mCurrentActivityRef
=
new
WeakReference
<>(
activity
);
if
(!
getDartExecutor
().
isExecutingDart
())
{
Debuger
.
log
(
"engine start running..."
);
getNavigationChannel
().
setInitialRoute
(
mInitRoute
);
getDartExecutor
().
executeDartEntrypoint
(
mEntrypoint
);
final
IStateListener
stateListener
=
FlutterBoost
.
sInstance
.
mStateListener
;
if
(
stateListener
!=
null
)
{
stateListener
.
onEngineStarted
(
this
);
}
FlutterBoost
.
singleton
().
platform
().
registerPlugins
(
mBoostPluginRegistry
);
if
(
activity
!=
null
)
{
FlutterRenderer
.
ViewportMetrics
metrics
=
new
FlutterRenderer
.
ViewportMetrics
();
metrics
.
devicePixelRatio
=
activity
.
getResources
().
getDisplayMetrics
().
density
;
final
View
decor
=
activity
.
getWindow
().
getDecorView
();
if
(
decor
!=
null
)
{
metrics
.
width
=
decor
.
getWidth
();
metrics
.
height
=
decor
.
getHeight
();
}
if
(
metrics
.
width
<=
0
||
metrics
.
height
<=
0
)
{
metrics
.
width
=
Utils
.
getMetricsWidth
(
activity
);
metrics
.
height
=
Utils
.
getMetricsHeight
(
activity
);
}
metrics
.
paddingTop
=
Utils
.
getStatusBarHeight
(
activity
);
metrics
.
paddingRight
=
0
;
metrics
.
paddingBottom
=
0
;
metrics
.
paddingLeft
=
0
;
metrics
.
viewInsetTop
=
0
;
metrics
.
viewInsetRight
=
0
;
metrics
.
viewInsetBottom
=
0
;
metrics
.
viewInsetLeft
=
0
;
getRenderer
().
setViewportMetrics
(
metrics
);
}
}
}
// public BoostFlutterEngine(@NonNull Context context, DartExecutor.DartEntrypoint entrypoint, String initRoute) {
// super(context);
// mContext = context.getApplicationContext();
//// mBoostPluginRegistry = new BoostPluginRegistry(this, context);
//
// if (entrypoint != null) {
// mEntrypoint = entrypoint;
// } else {
// mEntrypoint = defaultDartEntrypoint(context);
// }
//
// if (initRoute != null) {
// mInitRoute = initRoute;
// } else {
// mInitRoute = defaultInitialRoute(context);
// }
//
// FlutterJNI flutterJNI = null;
// try {
// Field field = FlutterEngine.class.getDeclaredField("flutterJNI");
// field.setAccessible(true);
//
// flutterJNI = (FlutterJNI) field.get(this);
// } catch (Throwable t) {
// try {
// for(Field field:FlutterEngine.class.getDeclaredFields()) {
// field.setAccessible(true);
// Object o = field.get(this);
//
// if(o instanceof FlutterJNI) {
// flutterJNI = (FlutterJNI)o;
// }
// }
//
// if(flutterJNI == null) {
// throw new RuntimeException("FlutterJNI not found");
// }
// }catch (Throwable it){
// Debuger.exception(it);
// }
// }
// mFakeRender = new FakeRender(flutterJNI);
// }
// public void startRun(@Nullable Activity activity) {
// mCurrentActivityRef = new WeakReference<>(activity);
//
// if (!getDartExecutor().isExecutingDart()) {
//
// Debuger.log("engine start running...");
//
// getNavigationChannel().setInitialRoute(mInitRoute);
// getDartExecutor().executeDartEntrypoint(mEntrypoint);
//
// final IStateListener stateListener = FlutterBoost.sInstance.mStateListener;
// if (stateListener != null) {
// stateListener.onEngineStarted(this);
// }
//
//// FlutterBoost.singleton().platform().registerPlugins(mBoostPluginRegistry);
//
// if(activity != null) {
// FlutterRenderer.ViewportMetrics metrics = new FlutterRenderer.ViewportMetrics();
// metrics.devicePixelRatio = activity.getResources().getDisplayMetrics().density;
// final View decor = activity.getWindow().getDecorView();
// if(decor != null) {
// metrics.width = decor.getWidth();
// metrics.height = decor.getHeight();
// }
//
// if (metrics.width <= 0 || metrics.height <= 0) {
// metrics.width = Utils.getMetricsWidth(activity);
// metrics.height = Utils.getMetricsHeight(activity);
// }
//
// metrics.paddingTop = Utils.getStatusBarHeight(activity);
// metrics.paddingRight = 0;
// metrics.paddingBottom = 0;
// metrics.paddingLeft = 0;
// metrics.viewInsetTop = 0;
// metrics.viewInsetRight = 0;
// metrics.viewInsetBottom = 0;
// metrics.viewInsetLeft = 0;
//
// getRenderer().setViewportMetrics(metrics);
// }
// }
// }
protected
DartExecutor
.
DartEntrypoint
defaultDartEntrypoint
(
Context
context
)
{
return
new
DartExecutor
.
DartEntrypoint
(
context
.
getResources
().
getAssets
(),
FlutterMain
.
findAppBundlePath
(
context
),
"main"
);
return
DartExecutor
.
DartEntrypoint
.
createDefault
();
}
protected
String
defaultInitialRoute
(
Context
context
)
{
return
"/"
;
}
public
BoostPluginRegistry
getBoostPluginRegistry
()
{
return
mBoostPluginRegistry
;
}
//
public BoostPluginRegistry getBoostPluginRegistry() {
//
return mBoostPluginRegistry;
//
}
public
boolean
isRunning
()
{
return
getDartExecutor
().
isExecutingDart
();
...
...
@@ -165,14 +157,14 @@ public class BoostFlutterEngine extends FlutterEngine {
}
if
(
hit
)
{
return
mFakeRender
;
return
null
;
}
else
{
return
super
.
getRenderer
();
}
}
public
class
BoostPluginRegistry
extends
FlutterPluginRegistry
{
private
final
FlutterEngine
mEngine
;
private
FlutterEngine
mEngine
;
public
BoostPluginRegistry
(
FlutterEngine
engine
,
Context
context
)
{
super
(
engine
,
context
);
...
...
@@ -184,7 +176,7 @@ public class BoostFlutterEngine extends FlutterEngine {
}
}
public
class
BoostRegistrar
implements
PluginRegistry
.
Registrar
{
public
class
BoostRegistrar
implements
PluginRegistry
.
Registrar
{
private
final
PluginRegistry
.
Registrar
mRegistrar
;
private
final
FlutterEngine
mEngine
;
...
...
android/src/main/java/com/idlefish/flutterboost/BoostFlutterView.java
View file @
d9ac3683
...
...
@@ -136,7 +136,7 @@ public class BoostFlutterView extends FrameLayout {
mFlutterView
.
addOnFirstFrameRenderedListener
(
mOnFirstFrameRenderedListener
);
mFlutterEngine
.
startRun
((
Activity
)
getContext
());
//
mFlutterEngine.startRun((Activity)getContext());
final
IStateListener
stateListener
=
FlutterBoost
.
sInstance
.
mStateListener
;
if
(
stateListener
!=
null
)
{
...
...
@@ -185,7 +185,8 @@ public class BoostFlutterView extends FrameLayout {
}
protected
BoostFlutterEngine
createFlutterEngine
(
Context
context
)
{
return
FlutterBoost
.
singleton
().
engineProvider
().
provideEngine
(
context
);
// return FlutterBoost.singleton().engineProvider().provideEngine(context);
return
null
;
}
public
void
addFirstFrameRendered
(
OnFirstFrameRenderedListener
listener
)
{
...
...
@@ -310,7 +311,7 @@ public class BoostFlutterView extends FrameLayout {
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
grantResults
)
{
if
(
mFlutterEngine
!=
null
)
{
mFlutterEngine
.
getPluginRegistry
().
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
//
mFlutterEngine.getPluginRegistry().onRequestPermissionsResult(requestCode, permissions, grantResults);
}
else
{
Debuger
.
log
(
"onRequestPermissionResult() invoked before BoostFlutterView was attached to an Activity."
);
}
...
...
@@ -319,7 +320,7 @@ public class BoostFlutterView extends FrameLayout {
public
void
onNewIntent
(
Intent
intent
)
{
if
(
mFlutterEngine
!=
null
)
{
mFlutterEngine
.
getPluginRegistry
().
onNewIntent
(
intent
);
//
mFlutterEngine.getPluginRegistry().onNewIntent(intent);
}
else
{
Debuger
.
log
(
"onNewIntent() invoked before BoostFlutterView was attached to an Activity."
);
}
...
...
@@ -328,7 +329,7 @@ public class BoostFlutterView extends FrameLayout {
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
mFlutterEngine
!=
null
)
{
mFlutterEngine
.
getPluginRegistry
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
//
mFlutterEngine.getPluginRegistry().onActivityResult(requestCode, resultCode, data);
}
else
{
Debuger
.
log
(
"onActivityResult() invoked before BoostFlutterView was attached to an Activity."
);
}
...
...
@@ -336,7 +337,7 @@ public class BoostFlutterView extends FrameLayout {
public
void
onUserLeaveHint
()
{
if
(
mFlutterEngine
!=
null
)
{
mFlutterEngine
.
getPluginRegistry
().
onUserLeaveHint
();
//
mFlutterEngine.getPluginRegistry().onUserLeaveHint();
}
else
{
Debuger
.
log
(
"onUserLeaveHint() invoked before BoostFlutterView was attached to an Activity."
);
}
...
...
android/src/main/java/com/idlefish/flutterboost/BoostPluginRegistry.java
0 → 100644
View file @
d9ac3683
package
com.idlefish.flutterboost
;
import
android.app.Activity
;
import
android.content.Context
;
import
com.idlefish.flutterboost.interfaces.IContainerRecord
;
import
io.flutter.app.FlutterPluginRegistry
;
import
io.flutter.embedding.engine.FlutterEngine
;
import
io.flutter.plugin.common.BinaryMessenger
;
import
io.flutter.plugin.common.PluginRegistry
;
import
io.flutter.plugin.platform.PlatformViewRegistry
;
import
io.flutter.view.FlutterView
;
import
io.flutter.view.TextureRegistry
;
import
java.lang.ref.WeakReference
;
public
class
BoostPluginRegistry
extends
FlutterPluginRegistry
{
protected
WeakReference
<
Activity
>
mCurrentActivityRef
;
private
FlutterEngine
mEngine
;
public
BoostPluginRegistry
(
FlutterEngine
engine
,
Context
context
)
{
super
(
engine
,
context
);
mEngine
=
engine
;
}
public
PluginRegistry
.
Registrar
registrarFor
(
String
pluginKey
)
{
return
new
BoostRegistrar
(
mEngine
,
super
.
registrarFor
(
pluginKey
));
}
public
class
BoostRegistrar
implements
PluginRegistry
.
Registrar
{
private
final
PluginRegistry
.
Registrar
mRegistrar
;
private
final
FlutterEngine
mEngine
;
BoostRegistrar
(
FlutterEngine
engine
,
PluginRegistry
.
Registrar
registrar
)
{
mRegistrar
=
registrar
;
mEngine
=
engine
;
}
@Override
public
Activity
activity
()
{
Activity
activity
;
IContainerRecord
record
;
record
=
FlutterBoost
.
singleton
().
containerManager
().
getCurrentTopRecord
();
if
(
record
==
null
)
{
record
=
FlutterBoost
.
singleton
().
containerManager
().
getLastGenerateRecord
();
}
if
(
record
==
null
)
{
activity
=
FlutterBoost
.
singleton
().
currentActivity
();
}
else
{
activity
=
record
.
getContainer
().
getContextActivity
();
}
if
(
activity
==
null
&&
mCurrentActivityRef
!=
null
)
{
activity
=
mCurrentActivityRef
.
get
();
}
if
(
activity
==
null
)
{
throw
new
RuntimeException
(
"current has no valid Activity yet"
);
}
return
activity
;
}
@Override
public
Context
context
()
{
return
mRegistrar
.
context
();
}
@Override
public
Context
activeContext
()
{
return
mRegistrar
.
activeContext
();
}
@Override
public
BinaryMessenger
messenger
()
{
return
mEngine
.
getDartExecutor
();
}
@Override
public
TextureRegistry
textures
()
{
return
mEngine
.
getRenderer
();
}
@Override
public
PlatformViewRegistry
platformViewRegistry
()
{
return
mRegistrar
.
platformViewRegistry
();
}
@Override
public
FlutterView
view
()
{
throw
new
RuntimeException
(
"should not use!!!"
);
}
@Override
public
String
lookupKeyForAsset
(
String
s
)
{
return
mRegistrar
.
lookupKeyForAsset
(
s
);
}
@Override
public
String
lookupKeyForAsset
(
String
s
,
String
s1
)
{
return
mRegistrar
.
lookupKeyForAsset
(
s
,
s1
);
}
@Override
public
PluginRegistry
.
Registrar
publish
(
Object
o
)
{
return
mRegistrar
.
publish
(
o
);
}
@Override
public
PluginRegistry
.
Registrar
addRequestPermissionsResultListener
(
PluginRegistry
.
RequestPermissionsResultListener
requestPermissionsResultListener
)
{
return
mRegistrar
.
addRequestPermissionsResultListener
(
requestPermissionsResultListener
);
}
@Override
public
PluginRegistry
.
Registrar
addActivityResultListener
(
PluginRegistry
.
ActivityResultListener
activityResultListener
)
{
return
mRegistrar
.
addActivityResultListener
(
activityResultListener
);
}
@Override
public
PluginRegistry
.
Registrar
addNewIntentListener
(
PluginRegistry
.
NewIntentListener
newIntentListener
)
{
return
mRegistrar
.
addNewIntentListener
(
newIntentListener
);
}
@Override
public
PluginRegistry
.
Registrar
addUserLeaveHintListener
(
PluginRegistry
.
UserLeaveHintListener
userLeaveHintListener
)
{
return
mRegistrar
.
addUserLeaveHintListener
(
userLeaveHintListener
);
}
@Override
public
PluginRegistry
.
Registrar
addViewDestroyListener
(
PluginRegistry
.
ViewDestroyListener
viewDestroyListener
)
{
return
mRegistrar
.
addViewDestroyListener
(
viewDestroyListener
);
}
}
}
android/src/main/java/com/idlefish/flutterboost/ContainerRecord.java
View file @
d9ac3683
...
...
@@ -76,7 +76,7 @@ public class ContainerRecord implements IContainerRecord {
}
mState
=
STATE_CREATED
;
mContainer
.
getBoostFlutterView
().
onResume
();
//
mContainer.getBoostFlutterView().onResume();
mProxy
.
create
();
}
...
...
@@ -129,15 +129,15 @@ public class ContainerRecord implements IContainerRecord {
mProxy
.
destroy
();
mContainer
.
getBoostFlutterView
().
onDestroy
();
//
mContainer.getBoostFlutterView().onDestroy();
mManager
.
removeRecord
(
this
);
mManager
.
setContainerResult
(
this
,-
1
,-
1
,
null
);
if
(!
mManager
.
hasContainerAppear
())
{
mContainer
.
getBoostFlutterView
().
onPause
();
mContainer
.
getBoostFlutterView
().
onStop
();
//
mContainer.getBoostFlutterView().onPause();
//
mContainer.getBoostFlutterView().onStop();
}
}
...
...
@@ -154,45 +154,80 @@ public class ContainerRecord implements IContainerRecord {
map
.
put
(
"name"
,
mContainer
.
getContainerUrl
());
map
.
put
(
"uniqueId"
,
mUniqueId
);
FlutterBoost
.
singleton
().
channel
().
sendEvent
(
"lifecycle"
,
map
);
NewFlutterBoost
.
instance
().
channel
().
sendEvent
(
"lifecycle"
,
map
);
mContainer
.
getBoostFlutterView
().
onBackPressed
();
//
mContainer.getBoostFlutterView().onBackPressed();
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
grantResults
)
{
mContainer
.
getBoostFlutterView
().
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
}
@Override
public
void
onNewIntent
(
Intent
intent
)
{
mContainer
.
getBoostFlutterView
().
onNewIntent
(
intent
);
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
mContainer
.
getBoostFlutterView
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
}
@Override
public
void
onContainerResult
(
int
requestCode
,
int
resultCode
,
Map
<
String
,
Object
>
result
)
{
mManager
.
setContainerResult
(
this
,
requestCode
,
resultCode
,
result
);
}
@Override
public
void
onUserLeaveHint
()
{
mContainer
.
getBoostFlutterView
().
onUserLeaveHint
();
}
@Override
public
void
onTrimMemory
(
int
level
)
{
mContainer
.
getBoostFlutterView
().
onTrimMemory
(
level
);
}
@Override
public
void
onLowMemory
()
{
mContainer
.
getBoostFlutterView
().
onLowMemory
();
}
//
// @Override
// public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
// mContainer.getBoostFlutterView().onRequestPermissionsResult(requestCode, permissions, grantResults);
// }
//
// @Override
// public void onNewIntent(Intent intent) {
// mContainer.getBoostFlutterView().onNewIntent(intent);
// }
//
// @Override
// public void onActivityResult(int requestCode, int resultCode, Intent data) {
// mContainer.getBoostFlutterView().onActivityResult(requestCode, resultCode, data);
// }
//
// @Override
// public void onContainerResult(int requestCode, int resultCode, Map<String, Object> result) {
// mManager.setContainerResult(this, requestCode,resultCode, result);
// }
//
// @Override
// public void onUserLeaveHint() {
// mContainer.getBoostFlutterView().onUserLeaveHint();
// }
//
// @Override
// public void onTrimMemory(int level) {
// mContainer.getBoostFlutterView().onTrimMemory(level);
// }
//
// @Override
// public void onLowMemory() {
// mContainer.getBoostFlutterView().onLowMemory();
// }
private
class
MethodChannelProxy
{
...
...
@@ -252,7 +287,7 @@ public class ContainerRecord implements IContainerRecord {
args
.
put
(
"pageName"
,
url
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
FlutterBoost
.
singleton
().
channel
().
invokeMethod
(
method
,
args
);
NewFlutterBoost
.
instance
().
channel
().
invokeMethod
(
method
,
args
);
}
public
void
invokeChannelUnsafe
(
String
method
,
String
url
,
Map
params
,
String
uniqueId
)
{
...
...
@@ -260,7 +295,7 @@ public class ContainerRecord implements IContainerRecord {
args
.
put
(
"pageName"
,
url
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
FlutterBoost
.
singleton
().
channel
().
invokeMethodUnsafe
(
method
,
args
);
NewFlutterBoost
.
instance
().
channel
().
invokeMethodUnsafe
(
method
,
args
);
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
View file @
d9ac3683
...
...
@@ -51,11 +51,11 @@ public class FlutterBoost {
sInstance
=
new
FlutterBoost
(
platform
);
}
if
(
platform
.
whenEngineStart
()
==
IPlatform
.
IMMEDIATELY
)
{
sInstance
.
mEngineProvider
.
provideEngine
(
platform
.
getApplication
())
.
startRun
(
null
);
}
//
if (platform.whenEngineStart() == IPlatform.IMMEDIATELY) {
//
sInstance.mEngineProvider
//
.provideEngine(platform.getApplication())
//
.startRun(null);
//
}
}
public
static
FlutterBoost
singleton
()
{
...
...
@@ -84,9 +84,9 @@ public class FlutterBoost {
mEngineProvider
=
provider
;
platform
.
getApplication
().
registerActivityLifecycleCallbacks
(
new
ActivityLifecycleCallbacks
());
BoostChannel
.
addActionAfterRegistered
(
new
BoostChannel
.
ActionAfterRegistered
()
{
FlutterBoostPlugin
.
addActionAfterRegistered
(
new
FlutterBoostPlugin
.
ActionAfterRegistered
()
{
@Override
public
void
onChannelRegistered
(
BoostChannel
channel
)
{
public
void
onChannelRegistered
(
FlutterBoostPlugin
channel
)
{
channel
.
addMethodCallHandler
(
new
BoostMethodHandler
());
}
});
...
...
@@ -104,8 +104,8 @@ public class FlutterBoost {
return
sInstance
.
mPlatform
;
}
public
BoostChannel
channel
()
{
return
BoostChannel
.
singleton
();
public
FlutterBoostPlugin
channel
()
{
return
FlutterBoostPlugin
.
singleton
();
}
public
Activity
currentActivity
()
{
...
...
@@ -124,9 +124,9 @@ public class FlutterBoost {
@Override
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
if
(
platform
().
whenEngineStart
()
==
IPlatform
.
ANY_ACTIVITY_CREATED
)
{
sInstance
.
mEngineProvider
.
provideEngine
(
activity
)
.
startRun
(
activity
);
//
sInstance.mEngineProvider
//
.provideEngine(activity)
//
.startRun(activity);
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/
BoostChannel
.java
→
android/src/main/java/com/idlefish/flutterboost/
FlutterBoostPlugin
.java
View file @
d9ac3683
This diff is collapsed.
Click to expand it.
android/src/main/java/com/idlefish/flutterboost/FlutterViewContainerManager.java
View file @
d9ac3683
...
...
@@ -111,9 +111,9 @@ public class FlutterViewContainerManager implements IContainerManager {
}
void
openContainer
(
String
url
,
Map
<
String
,
Object
>
urlParams
,
Map
<
String
,
Object
>
exts
,
OnResult
onResult
)
{
Context
context
=
FlutterBoost
.
singleton
().
currentActivity
();
Context
context
=
NewFlutterBoost
.
instance
().
currentActivity
();
if
(
context
==
null
)
{
context
=
FlutterBoost
.
singleton
().
platform
().
getApplication
();
context
=
NewFlutterBoost
.
instance
().
platform
().
getApplication
();
}
if
(
urlParams
==
null
)
{
...
...
@@ -132,7 +132,7 @@ public class FlutterViewContainerManager implements IContainerManager {
mOnResults
.
put
(
uniqueId
,
onResult
);
}
FlutterBoost
.
singleton
().
platform
().
openContainer
(
context
,
url
,
urlParams
,
requestCode
,
exts
);
NewFlutterBoost
.
instance
().
platform
().
openContainer
(
context
,
url
,
urlParams
,
requestCode
,
exts
);
}
IContainerRecord
closeContainer
(
String
uniqueId
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
)
{
...
...
@@ -148,7 +148,7 @@ public class FlutterViewContainerManager implements IContainerManager {
Debuger
.
exception
(
"closeContainer can not find uniqueId:"
+
uniqueId
);
}
FlutterBoost
.
singleton
().
platform
().
closeContainer
(
targetRecord
,
result
,
exts
);
NewFlutterBoost
.
instance
().
platform
().
closeContainer
(
targetRecord
,
result
,
exts
);
return
targetRecord
;
}
...
...
android/src/main/java/com/idlefish/flutterboost/NewFlutterBoost.java
0 → 100644
View file @
d9ac3683
package
com.idlefish.flutterboost
;
import
android.app.Activity
;
import
android.app.Application
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
com.idlefish.flutterboost.interfaces.*
;
import
io.flutter.app.FlutterPluginRegistry
;
import
io.flutter.embedding.engine.FlutterEngine
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
NewFlutterBoost
{
private
Platform
mPlatform
;
private
FlutterViewContainerManager
mManager
;
private
IFlutterEngineProvider
mEngineProvider
;
private
Activity
mCurrentActiveActivity
;
static
NewFlutterBoost
sInstance
=
null
;
public
static
NewFlutterBoost
instance
()
{
if
(
sInstance
==
null
)
{
sInstance
=
new
NewFlutterBoost
();
}
return
sInstance
;
}
public
void
init
(
Platform
platform
)
{
mPlatform
=
platform
;
mManager
=
new
FlutterViewContainerManager
();
mEngineProvider
=
platform
.
engineProvider
();
platform
.
getApplication
().
registerActivityLifecycleCallbacks
(
new
Application
.
ActivityLifecycleCallbacks
()
{
@Override
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
if
(
mPlatform
.
whenEngineStart
()
==
IPlatform
.
ANY_ACTIVITY_CREATED
)
{
}
}
@Override
public
void
onActivityStarted
(
Activity
activity
)
{
if
(
mCurrentActiveActivity
==
null
)
{
Debuger
.
log
(
"Application entry foreground"
);
if
(
NewFlutterBoost
.
instance
().
engineProvider
().
tryGetEngine
()
!=
null
)
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"type"
,
"foreground"
);
channel
().
sendEvent
(
"lifecycle"
,
map
);
}
}
mCurrentActiveActivity
=
activity
;
}
@Override
public
void
onActivityResumed
(
Activity
activity
)
{
mCurrentActiveActivity
=
activity
;
}
@Override
public
void
onActivityPaused
(
Activity
activity
)
{
}
@Override
public
void
onActivityStopped
(
Activity
activity
)
{
if
(
mCurrentActiveActivity
==
activity
)
{
Debuger
.
log
(
"Application entry background"
);
if
(
mEngineProvider
.
tryGetEngine
()
!=
null
)
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"type"
,
"background"
);
channel
().
sendEvent
(
"lifecycle"
,
map
);
}
mCurrentActiveActivity
=
null
;
}
}
@Override
public
void
onActivitySaveInstanceState
(
Activity
activity
,
Bundle
outState
)
{
}
@Override
public
void
onActivityDestroyed
(
Activity
activity
)
{
if
(
mCurrentActiveActivity
==
activity
)
{
Debuger
.
log
(
"Application entry background"
);
if
(
mEngineProvider
.
tryGetEngine
()
!=
null
)
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"type"
,
"background"
);
channel
().
sendEvent
(
"lifecycle"
,
map
);
}
mCurrentActiveActivity
=
null
;
}
}
});
BoostPluginRegistry
registry
=
new
BoostPluginRegistry
(
this
.
engineProvider
().
provideEngine
(
mPlatform
.
getApplication
()),
mPlatform
.
getApplication
());
mPlatform
.
registerPlugins
(
registry
);
}
public
static
class
ConfigBuilder
{
protected
static
final
String
DEFAULT_DART_ENTRYPOINT
=
"main"
;
protected
static
final
String
DEFAULT_INITIAL_ROUTE
=
"/"
;
private
String
dartEntrypoint
=
DEFAULT_DART_ENTRYPOINT
;
private
String
initialRoute
=
DEFAULT_INITIAL_ROUTE
;
private
boolean
isDebug
=
false
;
private
int
whenEngineStart
=
1
;
private
Application
mApp
;
private
INativeRouter
router
=
null
;
public
ConfigBuilder
(
Application
app
,
INativeRouter
router
)
{
this
.
router
=
router
;
this
.
mApp
=
app
;
}
public
ConfigBuilder
dartEntrypoint
(
@NonNull
String
dartEntrypoint
)
{
this
.
dartEntrypoint
=
dartEntrypoint
;
return
this
;
}
public
ConfigBuilder
isDebug
(
boolean
isDebug
)
{
this
.
isDebug
=
isDebug
;
return
this
;
}
public
ConfigBuilder
whenEngineStart
(
@NonNull
int
whenEngineStart
)
{
this
.
whenEngineStart
=
whenEngineStart
;
return
this
;
}
public
Platform
build
()
{
Platform
platform
=
new
Platform
()
{
@Override
public
Application
getApplication
()
{
return
ConfigBuilder
.
this
.
mApp
;
}
public
boolean
isDebug
()
{
return
ConfigBuilder
.
this
.
isDebug
;
}
@Override
public
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
)
{
router
.
openContainer
(
context
,
url
,
urlParams
,
requestCode
,
exts
);
}
@Override
public
IFlutterEngineProvider
engineProvider
()
{
return
new
BoostEngineProvider
();
}
public
int
whenEngineStart
()
{
return
ConfigBuilder
.
this
.
whenEngineStart
;
}
};
return
platform
;
}
}
public
IFlutterEngineProvider
engineProvider
()
{
return
sInstance
.
mEngineProvider
;
}
public
IContainerManager
containerManager
()
{
return
sInstance
.
mManager
;
}
public
IPlatform
platform
()
{
return
sInstance
.
mPlatform
;
}
public
FlutterBoostPlugin
channel
()
{
return
FlutterBoostPlugin
.
singleton
();
}
public
Activity
currentActivity
()
{
return
sInstance
.
mCurrentActiveActivity
;
}
public
IFlutterViewContainer
findContainerById
(
String
id
)
{
return
mManager
.
findContainerById
(
id
);
}
}
android/src/main/java/com/idlefish/flutterboost/StateListener.java
View file @
d9ac3683
...
...
@@ -16,7 +16,7 @@ public class StateListener implements IStateListener {
}
@Override
public
void
onChannelRegistered
(
PluginRegistry
.
Registrar
registrar
,
BoostChannel
channel
)
{
public
void
onChannelRegistered
(
PluginRegistry
.
Registrar
registrar
,
FlutterBoostPlugin
channel
)
{
Debuger
.
log
(
">>onFlutterViewInited"
);
}
...
...
android/src/main/java/com/idlefish/flutterboost/XFlutterView.java
View file @
d9ac3683
...
...
@@ -449,7 +449,7 @@ public class XFlutterView extends FrameLayout {
this
.
flutterEngine
=
flutterEngine
;
// initialize PlatformViewsController
this
.
flutterEngine
.
getPluginRegistry
().
getPlatformViewsController
().
attach
(
getContext
(),
flutterEngine
.
getRenderer
(),
flutterEngine
.
getDartExecutor
());
//
this.flutterEngine.getPluginRegistry().getPlatformViewsController().attach(getContext(),flutterEngine.getRenderer(),flutterEngine.getDartExecutor());
// Instruct our FlutterRenderer that we are now its designated RenderSurface.
this
.
flutterEngine
.
getRenderer
().
attachToRenderSurface
(
renderSurface
);
...
...
@@ -533,8 +533,8 @@ public class XFlutterView extends FrameLayout {
Log
.
d
(
TAG
,
"Detaching from Flutter Engine"
);
// detach platformviews in page in case memory leak
flutterEngine
.
getPluginRegistry
().
getPlatformViewsController
().
detach
();
flutterEngine
.
getPluginRegistry
().
getPlatformViewsController
().
onFlutterViewDestroyed
();
//
flutterEngine.getPluginRegistry().getPlatformViewsController().detach();
//
flutterEngine.getPluginRegistry().getPlatformViewsController().onFlutterViewDestroyed();
// Inform the Android framework that it should retrieve a new InputConnection
// now that the engine is detached. The new InputConnection will be null, which
...
...
android/src/main/java/com/idlefish/flutterboost/XTextInputPlugin.java
View file @
d9ac3683
package
com.idlefish.flutterboost
;
import
android.content.Context
;
import
android.os.Build
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.RequiresApi
;
import
android.text.Editable
;
import
android.text.InputType
;
import
android.text.Selection
;
...
...
@@ -59,6 +61,11 @@ public class XTextInputPlugin {
setTextInputClient
(
textInputClientId
,
configuration
);
}
@Override
public
void
setPlatformViewClient
(
int
i
)
{
}
@Override
public
void
setEditingState
(
TextInputChannel
.
TextEditState
editingState
)
{
setTextInputEditingState
(
mView
,
editingState
);
...
...
@@ -206,6 +213,7 @@ public class XTextInputPlugin {
}
}
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
CUPCAKE
)
private
void
setTextInputEditingState
(
View
view
,
TextInputChannel
.
TextEditState
state
)
{
if
(!
mRestartInputPending
&&
state
.
text
.
equals
(
mEditable
.
toString
()))
{
applyStateToSelection
(
state
);
...
...
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterActivity.java
100755 → 100644
View file @
d9ac3683
...
...
@@ -117,7 +117,8 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
}
protected
BoostFlutterEngine
createFlutterEngine
(){
return
FlutterBoost
.
singleton
().
engineProvider
().
provideEngine
(
this
);
// return FlutterBoost.singleton().engineProvider().provideEngine(this);
return
null
;
}
protected
BoostFlutterView
createFlutterView
(
BoostFlutterEngine
engine
){
...
...
@@ -247,10 +248,10 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
return
this
;
}
@Override
public
BoostFlutterView
getBoostFlutterView
()
{
return
mFlutterView
;
}
//
@Override
//
public BoostFlutterView getBoostFlutterView() {
//
return mFlutterView;
//
}
@Override
public
void
finishContainer
(
Map
<
String
,
Object
>
result
)
{
...
...
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterDefaultActivity.java
View file @
d9ac3683
...
...
@@ -9,6 +9,11 @@ import java.util.Map;
public
class
BoostFlutterDefaultActivity
extends
BoostFlutterActivity
{
@Override
public
FlutterSplashView
getBoostFlutterView
()
{
return
null
;
}
@Override
public
String
getContainerUrl
()
{
return
getIntent
().
getStringExtra
(
"url"
);
...
...
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterFragment.java
View file @
d9ac3683
...
...
@@ -67,7 +67,8 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
}
protected
BoostFlutterEngine
createFlutterEngine
(){
return
FlutterBoost
.
singleton
().
engineProvider
().
provideEngine
(
getContext
());
// return FlutterBoost.singleton().engineProvider().provideEngine(getContext());
return
null
;
}
protected
BoostFlutterView
createFlutterView
(
BoostFlutterEngine
engine
){
...
...
@@ -140,10 +141,10 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
return
getActivity
();
}
@Override
public
BoostFlutterView
getBoostFlutterView
()
{
return
mFlutterView
;
}
//
@Override
//
public BoostFlutterView getBoostFlutterView() {
//
return mFlutterView;
//
}
@Override
public
void
finishContainer
(
Map
<
String
,
Object
>
result
)
{
...
...
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
0 → 100644
View file @
d9ac3683
This diff is collapsed.
Click to expand it.
android/src/main/java/com/idlefish/flutterboost/containers/FlutterSplashView.java
0 → 100644
View file @
d9ac3683
This diff is collapsed.
Click to expand it.
android/src/main/java/com/idlefish/flutterboost/containers/NewBoostFlutterActivity.java
0 → 100644
View file @
d9ac3683
This diff is collapsed.
Click to expand it.
android/src/main/java/com/idlefish/flutterboost/interfaces/IFlutterEngineProvider.java
View file @
d9ac3683
...
...
@@ -26,6 +26,8 @@ package com.idlefish.flutterboost.interfaces;
import
android.content.Context
;
import
com.idlefish.flutterboost.BoostFlutterEngine
;
import
io.flutter.embedding.engine.FlutterEngine
;
/**
* a flutter engine provider
*/
...
...
@@ -36,18 +38,18 @@ public interface IFlutterEngineProvider {
* @param context
* @return
*/
Boost
FlutterEngine
createEngine
(
Context
context
);
FlutterEngine
createEngine
(
Context
context
);
/**
* provide a flutter engine
* @param context
* @return
*/
Boost
FlutterEngine
provideEngine
(
Context
context
);
FlutterEngine
provideEngine
(
Context
context
);
/**
* may return null
* @return
*/
Boost
FlutterEngine
tryGetEngine
();
FlutterEngine
tryGetEngine
();
}
android/src/main/java/com/idlefish/flutterboost/interfaces/IFlutterViewContainer.java
View file @
d9ac3683
...
...
@@ -26,6 +26,7 @@ package com.idlefish.flutterboost.interfaces;
import
android.app.Activity
;
import
com.idlefish.flutterboost.BoostFlutterView
;
import
com.idlefish.flutterboost.containers.FlutterSplashView
;
import
java.util.Map
;
...
...
@@ -41,7 +42,7 @@ public interface IFlutterViewContainer {
* provide a flutter view
* @return
*/
BoostFlutter
View
getBoostFlutterView
();
FlutterSplash
View
getBoostFlutterView
();
/**
* call to destroy the container
...
...
android/src/main/java/com/idlefish/flutterboost/interfaces/INativeRouter.java
0 → 100644
View file @
d9ac3683
package
com.idlefish.flutterboost.interfaces
;
import
android.content.Context
;
import
java.util.Map
;
public
interface
INativeRouter
{
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
);
void
closeContainer
(
IContainerRecord
record
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
);
}
android/src/main/java/com/idlefish/flutterboost/interfaces/IStateListener.java
View file @
d9ac3683
package
com.idlefish.flutterboost.interfaces
;
import
com.idlefish.flutterboost.
BoostChannel
;
import
com.idlefish.flutterboost.
FlutterBoostPlugin
;
import
com.idlefish.flutterboost.BoostFlutterEngine
;
import
com.idlefish.flutterboost.BoostFlutterView
;
...
...
@@ -9,7 +9,7 @@ import io.flutter.plugin.common.PluginRegistry;
public
interface
IStateListener
{
void
onEngineCreated
(
BoostFlutterEngine
engine
);
void
onEngineStarted
(
BoostFlutterEngine
engine
);
void
onChannelRegistered
(
PluginRegistry
.
Registrar
registrar
,
BoostChannel
channel
);
void
onChannelRegistered
(
PluginRegistry
.
Registrar
registrar
,
FlutterBoostPlugin
channel
);
void
onFlutterViewInited
(
BoostFlutterEngine
engine
,
BoostFlutterView
flutterView
);
void
beforeEngineAttach
(
BoostFlutterEngine
engine
,
BoostFlutterView
flutterView
);
void
afterEngineAttached
(
BoostFlutterEngine
engine
,
BoostFlutterView
flutterView
);
...
...
example/android/app/build.gradle
View file @
d9ac3683
...
...
@@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply
from:
"$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android
{
compileSdkVersion
2
6
compileSdkVersion
2
8
lintOptions
{
disable
'InvalidPackage'
...
...
@@ -35,7 +35,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId
"com.taobao.idlefish.flutterboostexample"
minSdkVersion
16
targetSdkVersion
2
6
targetSdkVersion
2
8
versionCode
flutterVersionCode
.
toInteger
()
versionName
flutterVersionName
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
...
...
@@ -53,11 +53,11 @@ android {
flutter
{
source
'../..'
}
dependencies
{
testImplementation
'junit:junit:4.12'
androidTestImplementation
'com.android.support.test:runner:1.0.2'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
implementation
'com.android.support:
support-v4:26.1
.0'
implementation
'com.android.support:appcompat-v7:26.1.0'
implementation
'com.android.support:
appcompat-v7:28.0
.0'
}
example/android/app/src/main/AndroidManifest.xml
View file @
d9ac3683
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.taobao.idlefish.flutterboostexample"
>
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.taobao.idlefish.flutterboostexample"
>
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
...
...
@@ -33,6 +34,10 @@
</intent-filter>
</activity>
<activity
android:name=
".FlutterPageActivity"
android:theme=
"@style/Theme.AppCompat"
...
...
@@ -40,6 +45,15 @@
android:hardwareAccelerated=
"true"
android:windowSoftInputMode=
"adjustResize"
/>
<activity
android:name=
"com.idlefish.flutterboost.containers.NewBoostFlutterActivity"
android:theme=
"@style/Theme.AppCompat"
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated=
"true"
android:windowSoftInputMode=
"adjustResize"
>
<!--<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/avd_hide_password"/>-->
</activity>
<activity
android:name=
".FlutterFragmentPageActivity"
android:theme=
"@style/Theme.AppCompat"
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterFragment.java
View file @
d9ac3683
...
...
@@ -4,6 +4,7 @@ import android.os.Bundle;
import
android.support.annotation.Nullable
;
import
com.idlefish.flutterboost.containers.BoostFlutterFragment
;
import
com.idlefish.flutterboost.containers.FlutterSplashView
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -25,6 +26,11 @@ public class FlutterFragment extends BoostFlutterFragment {
super
.
setArguments
(
args
);
}
@Override
public
FlutterSplashView
getBoostFlutterView
()
{
return
null
;
}
@Override
public
String
getContainerUrl
()
{
return
"flutterFragment"
;
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterPageActivity.java
View file @
d9ac3683
package
com.taobao.idlefish.flutterboostexample
;
import
com.idlefish.flutterboost.containers.BoostFlutterActivity
;
import
com.idlefish.flutterboost.containers.FlutterSplashView
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
FlutterPageActivity
extends
BoostFlutterActivity
{
@Override
public
FlutterSplashView
getBoostFlutterView
()
{
return
null
;
}
/**
* 该方法返回当前Activity在Flutter层对应的name,
* 混合栈将会在flutter层根据这个名字,在注册的Route表中查找对应的Widget
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
View file @
d9ac3683
...
...
@@ -3,66 +3,74 @@ package com.taobao.idlefish.flutterboostexample;
import
android.app.Application
;
import
android.content.Context
;
import
com.idlefish.flutterboost.BoostChannel
;
import
com.idlefish.flutterboost.BoostEngineProvider
;
import
com.idlefish.flutterboost.BoostFlutterEngine
;
import
com.idlefish.flutterboost.FlutterBoost
;
import
com.idlefish.flutterboost.Platform
;
import
com.idlefish.flutterboost.*
;
import
com.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.idlefish.flutterboost.interfaces.IFlutterEngineProvider
;
import
java.util.Map
;
import
com.idlefish.flutterboost.interfaces.INativeRouter
;
import
io.flutter.app.FlutterApplication
;
import
io.flutter.embedding.engine.dart.DartExecutor
;
import
io.flutter.view.FlutterMain
;
public
class
MyApplication
extends
FlutterApplication
{
@Override
public
void
onCreate
()
{
super
.
onCreate
();
//
// FlutterBoost.init(new Platform() {
//
// @Override
// public Application getApplication() {
// return MyApplication.this;
// }
//
// @Override
// public boolean isDebug() {
// return true;
// }
//
// @Override
// public void openContainer(Context context, String url, Map<String, Object> urlParams, int requestCode, Map<String, Object> exts) {
// PageRouter.openPageByUrl(context, url, urlParams, requestCode);
// }
//
// @Override
// public IFlutterEngineProvider engineProvider() {
// return new BoostEngineProvider() {
// @Override
// public BoostFlutterEngine createEngine(Context context) {
// return new BoostFlutterEngine(context);
// }
// };
// }
//
// @Override
// public int whenEngineStart() {
// return ANY_ACTIVITY_CREATED;
// }
// });
FlutterBoost
.
init
(
new
Platform
()
{
// FlutterBoostPlugin.addActionAfterRegistered(new FlutterBoostPlugin.ActionAfterRegistered() {
// @Override
// public void onChannelRegistered(FlutterBoostPlugin channel) {
// //platform view register should use FlutterPluginRegistry instread of BoostPluginRegistry
// TextPlatformViewPlugin.register(FlutterBoost.singleton().engineProvider().tryGetEngine().getPluginRegistry());
// }
// });
@Override
public
Application
getApplication
()
{
return
MyApplication
.
this
;
}
@Override
public
boolean
isDebug
()
{
return
true
;
}
INativeRouter
router
=
new
INativeRouter
()
{
@Override
public
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
)
{
PageRouter
.
openPageByUrl
(
context
,
url
,
urlParams
,
requestCode
);
PageRouter
.
openPageByUrl
(
context
,
url
,
urlParams
);
}
@Override
public
IFlutterEngineProvider
engineProvider
()
{
return
new
BoostEngineProvider
()
{
@Override
public
BoostFlutterEngine
createEngine
(
Context
context
)
{
return
new
BoostFlutterEngine
(
context
,
new
DartExecutor
.
DartEntrypoint
(
context
.
getResources
().
getAssets
(),
FlutterMain
.
findAppBundlePath
(
context
),
"main"
),
"/"
);
}
};
}
public
void
closeContainer
(
IContainerRecord
record
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
)
{
@Override
public
int
whenEngineStart
()
{
return
ANY_ACTIVITY_CREATED
;
}
});
BoostChannel
.
addActionAfterRegistered
(
new
BoostChannel
.
ActionAfterRegistered
()
{
@Override
public
void
onChannelRegistered
(
BoostChannel
channel
)
{
//platform view register should use FlutterPluginRegistry instread of BoostPluginRegistry
TextPlatformViewPlugin
.
register
(
FlutterBoost
.
singleton
().
engineProvider
().
tryGetEngine
().
getPluginRegistry
());
}
});
};
Platform
platform
=
new
NewFlutterBoost
.
ConfigBuilder
(
this
,
router
).
build
();
NewFlutterBoost
.
instance
().
init
(
platform
);
}
}
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/PageRouter.java
View file @
d9ac3683
...
...
@@ -3,6 +3,7 @@ package com.taobao.idlefish.flutterboostexample;
import
android.content.Context
;
import
android.content.Intent
;
import
android.text.TextUtils
;
import
com.idlefish.flutterboost.containers.NewBoostFlutterActivity
;
import
java.util.Map
;
...
...
@@ -19,10 +20,11 @@ public class PageRouter {
public
static
boolean
openPageByUrl
(
Context
context
,
String
url
,
Map
params
,
int
requestCode
)
{
try
{
if
(
url
.
startsWith
(
FLUTTER_PAGE_URL
))
{
context
.
startActivity
(
new
Intent
(
context
,
FlutterPageActivity
.
class
));
context
.
startActivity
(
NewBoostFlutterActivity
.
createDefaultIntent
(
context
));
return
true
;
}
else
if
(
url
.
startsWith
(
FLUTTER_FRAGMENT_PAGE_URL
))
{
context
.
startActivity
(
new
Intent
(
context
,
FlutterFragmentPageActivity
.
class
));
//
context.startActivity(new Intent(context, FlutterFragmentPageActivity.class));
return
true
;
}
else
if
(
url
.
startsWith
(
NATIVE_PAGE_URL
))
{
context
.
startActivity
(
new
Intent
(
context
,
NativePageActivity
.
class
));
...
...
example/ios/Runner/GeneratedPluginRegistrant.m
View file @
d9ac3683
...
...
@@ -3,12 +3,12 @@
//
#import "GeneratedPluginRegistrant.h"
#import <flutter_boost/
BoostChannel
.h>
#import <flutter_boost/
FlutterBoostPlugin
.h>
@implementation
GeneratedPluginRegistrant
+
(
void
)
registerWithRegistry
:(
NSObject
<
FlutterPluginRegistry
>*
)
registry
{
[
BoostChannel
registerWithRegistrar
:[
registry
registrarForPlugin
:
@"BoostChannel
"
]];
[
FlutterBoostPlugin
registerWithRegistrar
:[
registry
registrarForPlugin
:
@"FlutterBoostPlugin
"
]];
}
@end
example/lib/main.dart
View file @
d9ac3683
...
...
@@ -36,7 +36,7 @@ class _MyAppState extends State<MyApp> {
return
MaterialApp
(
title:
'Flutter Boost example'
,
builder:
FlutterBoost
.
init
(
postPush:
_onRoutePushed
),
home:
Container
());
home:
FlutterRouteWidget
());
}
void
_onRoutePushed
(
...
...
pubspec.yaml
View file @
d9ac3683
...
...
@@ -19,7 +19,7 @@ dependencies:
flutter
:
plugin
:
androidPackage
:
com.idlefish.flutterboost
pluginClass
:
BoostChannel
pluginClass
:
FlutterBoostPlugin
# To add assets to your plugin package, add an assets section, like this:
# assets:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment