Commit e9fe2517 authored by justin's avatar justin

Merge branch 'master' into v1.12.13-hotfixes

parents c09cb81c 9eac79fa
......@@ -57,11 +57,11 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
protected IOperateSyncer mSyncer;
FlutterActivityAndFragmentDelegate(@NonNull Host host) {
public FlutterActivityAndFragmentDelegate(@NonNull Host host) {
this.host = host;
}
void release() {
public void release() {
this.host = null;
this.flutterEngine = null;
this.flutterView = null;
......@@ -70,15 +70,15 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
@Nullable
FlutterEngine getFlutterEngine() {
public FlutterEngine getFlutterEngine() {
return flutterEngine;
}
XFlutterView getFlutterView() {
public XFlutterView getFlutterView() {
return flutterView;
}
void onAttach(@NonNull Context context) {
public void onAttach(@NonNull Context context) {
ensureAlive();
if (FlutterBoost.instance().platform().whenEngineStart() == FlutterBoost.ConfigBuilder.FLUTTER_ACTIVITY_CREATED) {
FlutterBoost.instance().doInitialFlutter();
......@@ -125,7 +125,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
@SuppressLint("ResourceType")
@NonNull
View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
Log.v(TAG, "Creating FlutterView.");
flutterEngine.getActivityControlSurface().attachToActivity(
host.getActivity(),
......@@ -154,7 +154,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onStart() {
public void onStart() {
Log.v(TAG, "onStart()");
ensureAlive();
......@@ -167,7 +167,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onResume() {
public void onResume() {
mSyncer.onAppear();
Log.v(TAG, "onResume()");
......@@ -185,7 +185,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onPostResume() {
public void onPostResume() {
Log.v(TAG, "onPostResume()");
ensureAlive();
Utils.setStatusBarLightMode(host.getActivity(), true);
......@@ -193,7 +193,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onPause() {
public void onPause() {
Log.v(TAG, "onPause()");
ensureAlive();
......@@ -202,14 +202,14 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onStop() {
public void onStop() {
Log.v(TAG, "onStop()");
ensureAlive();
}
void onDestroyView() {
public void onDestroyView() {
Log.v(TAG, "onDestroyView()");
mSyncer.onDestroy();
......@@ -219,7 +219,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onDetach() {
public void onDetach() {
Log.v(TAG, "onDetach()");
ensureAlive();
......@@ -236,14 +236,14 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onBackPressed() {
public void onBackPressed() {
mSyncer.onBackPressed();
ensureAlive();
}
void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
mSyncer.onRequestPermissionsResult(requestCode, permissions, grantResults);
ensureAlive();
......@@ -259,7 +259,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onNewIntent(@NonNull Intent intent) {
public void onNewIntent(@NonNull Intent intent) {
mSyncer.onNewIntent(intent);
ensureAlive();
......@@ -272,7 +272,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onActivityResult(int requestCode, int resultCode, Intent data) {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
mSyncer.onActivityResult(requestCode, resultCode, data);
Map<String, Object> result = null;
if (data != null) {
......@@ -298,7 +298,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onUserLeaveHint() {
public void onUserLeaveHint() {
ensureAlive();
if (flutterEngine != null) {
Log.v(TAG, "Forwarding onUserLeaveHint() to FlutterEngine.");
......@@ -309,7 +309,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
void onTrimMemory(int level) {
public void onTrimMemory(int level) {
mSyncer.onTrimMemory(level);
ensureAlive();
......@@ -325,7 +325,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
}
}
void onLowMemory() {
public void onLowMemory() {
Log.v(TAG, "Forwarding onLowMemory() to FlutterEngine.");
mSyncer.onLowMemory();
......@@ -401,7 +401,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
* The {@link FlutterActivity} or {@link FlutterFragment} that owns this
* {@code FlutterActivityAndFragmentDelegate}.
*/
/* package */ interface Host extends SplashScreenProvider, FlutterEngineProvider, FlutterEngineConfigurator {
public interface Host extends SplashScreenProvider, FlutterEngineProvider, FlutterEngineConfigurator {
/**
* Returns the {@link Context} that backs the host {@link Activity} or {@code Fragment}.
*/
......
......@@ -179,11 +179,10 @@ static NSUInteger kInstanceCounter = 0;
params:_params
uniqueId:self.uniqueIDString];
//Save some first time page info.
if(![FlutterBoostPlugin sharedInstance].fPagename){
[FlutterBoostPlugin sharedInstance].fPagename = _name;
[FlutterBoostPlugin sharedInstance].fPageId = self.uniqueIDString;
[FlutterBoostPlugin sharedInstance].fParams = _params;
}
[super viewWillAppear:animated];
[self.view setNeedsLayout];
......
......@@ -199,7 +199,7 @@ class BoostContainerState extends NavigatorState {
}
if (canPop()) {
return super.pop(result);
super.pop<T>(result);
} else {
if (T is Map<String, dynamic>) {
FlutterBoost.singleton
......@@ -208,7 +208,7 @@ class BoostContainerState extends NavigatorState {
FlutterBoost.singleton.close(uniqueId);
}
}
return false;
return true;
}
@override
......
......@@ -55,11 +55,7 @@ class FlutterBoost {
static ContainerManagerState get containerManager =>
_instance.containerManagerKey.currentState;
static TransitionBuilder init(
{TransitionBuilder builder,
PrePushRoute prePush,
PostPushRoute postPush}) {
if (Platform.isAndroid) {
static void onPageStart() {
WidgetsBinding.instance.addPostFrameCallback((_) {
singleton.channel.invokeMethod<Map>('pageOnStart').then((Map pageInfo) {
if (pageInfo == null || pageInfo.isEmpty) return;
......@@ -74,6 +70,21 @@ class FlutterBoost {
});
}
static TransitionBuilder init(
{TransitionBuilder builder,
PrePushRoute prePush,
PostPushRoute postPush}) {
if (Platform.isAndroid) {
onPageStart();
} else if (Platform.isIOS) {
assert(() {
() async {
onPageStart();
}();
return true;
}());
}
return (BuildContext context, Widget child) {
assert(child is Navigator, 'child must be Navigator, what is wrong?');
......
......@@ -137,7 +137,7 @@ void main() {
expect(find.text('Y', skipOffstage: false), findsNothing);
});
//
testWidgets('Navigator.of fails gracefully when not found in context',
testWidgets('Navigator.of gracefully when not found in context',
(WidgetTester tester) async {
const Key targetKey = Key('foo');
dynamic exception;
......@@ -148,7 +148,13 @@ void main() {
},
);
await tester.pumpWidget(widget);
await tester.pump(Duration(seconds: 1));
await tester.tap(find.byKey(targetKey));
await tester.pump(Duration(seconds: 1));
expect(exception, isInstanceOf<FlutterError>());
expect('$exception',
startsWith('Navigator operation requested with a context'));
......
......@@ -47,7 +47,7 @@ void main() {
group('Try to get the BoostPageRoute in the ancestor node', () {
testWidgets(
'obtain BoostPageRoute through the `BoostPageRoute.of(context)` method',
'obtain BoostPageRoute through the BoostPageRoute.of(context) method',
(WidgetTester tester) async {
dynamic boostPageRoute;
dynamic boostPageRouteFindByOfMethod;
......@@ -74,13 +74,15 @@ void main() {
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
// The route obtained from the ancestor node through the `of` method should be the same BoostPageRoute
// as the originally created BoostPageRoute
expect(boostPageRoute, boostPageRouteFindByOfMethod);
});
testWidgets(
'try to find BoostPageRoute through the `BoostPageRoute.of(context)` method, '
'try to find BoostPageRoute through the BoostPageRoute.of(context) method, '
'but it doesn\'t exist, the method should throw an Exception',
(WidgetTester tester) async {
dynamic contextCache;
......@@ -102,12 +104,13 @@ void main() {
),
);
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
expect(() => BoostPageRoute.of<dynamic>(contextCache), throwsException);
});
testWidgets(
'obtain BoostPageRoute through the `BoostPageRoute.tryOf(context)` method',
'obtain BoostPageRoute through the BoostPageRoute.tryOf(context) method',
(WidgetTester tester) async {
dynamic boostPageRoute;
dynamic boostPageRouteFindByOfMethod;
......@@ -134,6 +137,7 @@ void main() {
);
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
// The route obtained from the ancestor node through the `tryOf` method should be the same BoostPageRoute
// as the originally created BoostPageRoute
......@@ -142,7 +146,7 @@ void main() {
});
testWidgets(
'try to find BoostPageRoute through the `BoostPageRoute.tryOf(context)` method, '
'try to find BoostPageRoute through the BoostPageRoute.tryOf(context) method, '
'but it doesn\'t exist, the method should return null',
(WidgetTester tester) async {
dynamic boostPageRouteFindByOfMethod;
......@@ -168,6 +172,7 @@ void main() {
);
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
expect(boostPageRouteFindByOfMethod, null);
});
......
......@@ -7,10 +7,6 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('test iOS edge swipe then drop back at starting point works',
(WidgetTester tester) async {
//push app
});
test('test onMethodCall', () async {
FlutterBoost.singleton
......@@ -26,7 +22,7 @@ void main() {
try {
FlutterBoost.singleton.open("url");
} catch (e) {
expect(e, isNoSuchMethodError);
expect(e, isException);
}
try {
FlutterBoost.singleton.close("url");
......
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