diff --git a/engine/src/flutter/shell/platform/android/BUILD.gn b/engine/src/flutter/shell/platform/android/BUILD.gn
index 65ca610a9c..db6b752b4d 100644
--- a/engine/src/flutter/shell/platform/android/BUILD.gn
+++ b/engine/src/flutter/shell/platform/android/BUILD.gn
@@ -81,6 +81,7 @@ java_library("flutter_shell_java") {
"io/flutter/app/FlutterActivityDelegate.java",
"io/flutter/app/FlutterActivityEvents.java",
"io/flutter/app/FlutterApplication.java",
+ "io/flutter/app/FlutterFragmentActivity.java",
"io/flutter/plugin/common/ActivityLifecycleListener.java",
"io/flutter/plugin/common/BasicMessageChannel.java",
"io/flutter/plugin/common/BinaryCodec.java",
@@ -112,9 +113,19 @@ java_library("flutter_shell_java") {
"io/flutter/view/VsyncWaiter.java",
]
+ deps = [
+ ":android_support_v4",
+ ]
+
jar_path = "$root_out_dir/flutter_java.jar"
}
+java_prebuilt("android_support_v4") {
+ supports_android = true
+
+ jar_path = "//third_party/android_tools/sdk/extras/android/support/v4/android-support-v4.jar"
+}
+
copy("flutter_shell_assets") {
visibility = [ ":*" ]
diff --git a/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterFragmentActivity.java b/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterFragmentActivity.java
new file mode 100644
index 0000000000..12f9fbe632
--- /dev/null
+++ b/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterFragmentActivity.java
@@ -0,0 +1,145 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package io.flutter.app;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import io.flutter.app.FlutterActivityDelegate.ViewFactory;
+import io.flutter.plugin.common.PluginRegistry;
+import io.flutter.plugin.common.PluginRegistry.Registrar;
+import io.flutter.view.FlutterView;
+
+/**
+ * Base class for activities that use Flutter who also require the use of the
+ * Android v4 Support library's {@link FragmentActivity}. Applications that
+ * don't have this need will likely want to use {@link FlutterActivity} instead.
+ *
+ * Important! Flutter does not bundle the necessary Android
+ * v4 Support library classes for this class to work at runtime. It is the
+ * responsibility of the app developer using this class to ensure that they
+ * link against the v4 support library .jar file when creating their app to
+ * ensure that {@link FragmentActivity} is available at runtime.
+ *
+ * @see https://developer.android.com/topic/libraries/support-library/setup.html
+ */
+public class FlutterFragmentActivity
+ extends FragmentActivity implements FlutterView.Provider, PluginRegistry, ViewFactory {
+ private final FlutterActivityDelegate delegate = new FlutterActivityDelegate(this, this);
+
+ // These aliases ensure that the methods we forward to the delegate adhere
+ // to relevant interfaces versus just existing in FlutterActivityDelegate.
+ private final FlutterActivityEvents eventDelegate = delegate;
+ private final FlutterView.Provider viewProvider = delegate;
+ private final PluginRegistry pluginRegistry = delegate;
+
+ /**
+ * Returns the Flutter view used by this activity; will be null before
+ * {@link #onCreate(Bundle)} is called.
+ */
+ @Override
+ public FlutterView getFlutterView() {
+ return viewProvider.getFlutterView();
+ }
+
+ /**
+ * Hook for subclasses to customize the creation of the
+ * {@code FlutterView}.
+ *
+ * The default implementation returns {@code null}, which will cause the
+ * activity to use a newly instantiated full-screen view.
+ */
+ @Override
+ public FlutterView createFlutterView(Context context) {
+ return null;
+ }
+
+ @Override
+ public final boolean hasPlugin(String key) {
+ return pluginRegistry.hasPlugin(key);
+ }
+
+ @Override
+ public final T valuePublishedByPlugin(String pluginKey) {
+ return pluginRegistry.valuePublishedByPlugin(pluginKey);
+ }
+
+ @Override
+ public final Registrar registrarFor(String pluginKey) {
+ return pluginRegistry.registrarFor(pluginKey);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ eventDelegate.onCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ eventDelegate.onDestroy();
+ super.onDestroy();
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (!eventDelegate.onBackPressed()) {
+ super.onBackPressed();
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ eventDelegate.onPause();
+ }
+
+ @Override
+ protected void onPostResume() {
+ super.onPostResume();
+ eventDelegate.onPostResume();
+ }
+
+ // @Override - added in API level 23
+ public void onRequestPermissionsResult(
+ int requestCode, String[] permissions, int[] grantResults) {
+ eventDelegate.onRequestPermissionResult(requestCode, permissions, grantResults);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (!eventDelegate.onActivityResult(requestCode, resultCode, data)) {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ eventDelegate.onNewIntent(intent);
+ }
+
+ @Override
+ public void onUserLeaveHint() {
+ eventDelegate.onUserLeaveHint();
+ }
+
+ @Override
+ public void onTrimMemory(int level) {
+ eventDelegate.onTrimMemory(level);
+ }
+
+ @Override
+ public void onLowMemory() {
+ eventDelegate.onLowMemory();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ eventDelegate.onConfigurationChanged(newConfig);
+ }
+}
diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java
index aa63fba1b6..2f7599113e 100644
--- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java
+++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java
@@ -58,6 +58,12 @@ public interface PluginRegistry {
interface Registrar {
/**
* Returns the {@link Activity} that forms the plugin's operating context.
+ *
+ * Plugin authors should not assume the type returned by this method
+ * is any specific subclass of {@code Activity} (such as
+ * {@link io.flutter.app.FlutterActivity} or
+ * {@link io.flutter.app.FlutterFragmentActivity}), as applications
+ * are free to use any activity subclass.
*/
Activity activity();
diff --git a/engine/src/flutter/tools/licenses/lib/main.dart b/engine/src/flutter/tools/licenses/lib/main.dart
index 83d2b3d64d..8563a1861f 100644
--- a/engine/src/flutter/tools/licenses/lib/main.dart
+++ b/engine/src/flutter/tools/licenses/lib/main.dart
@@ -971,7 +971,7 @@ class RepositoryDirectory extends RepositoryEntry implements LicenseSource {
/// Searches the current and all parent directories (up to the license root)
/// for a license of the specified type.
- License _nearestAncestorLicenseWithType(type) {
+ License _nearestAncestorLicenseWithType(LicenseType type) {
License result = _localLicenseWithType(type);
if (result != null)
return result;
@@ -1180,7 +1180,7 @@ class RepositoryDirectory extends RepositoryEntry implements LicenseSource {
}
}
- Stream> _signatureStream(List files) async* {
+ Stream> _signatureStream(List files) async* {
for (RepositoryLicensedFile file in files) {
yield file.io.fullName.codeUnits;
yield file.io.readBytes();
@@ -1190,7 +1190,7 @@ class RepositoryDirectory extends RepositoryEntry implements LicenseSource {
/// Compute a signature representing a hash of all the licensed files within
/// this directory tree.
Future get signature async {
- List allFiles = _signatureFiles.toList();
+ List allFiles = _signatureFiles.toList();
allFiles.sort((RepositoryLicensedFile a, RepositoryLicensedFile b) =>
a.io.fullName.compareTo(b.io.fullName));
crypto.Digest digest = await crypto.md5.bind(_signatureStream(allFiles)).single;
@@ -2250,7 +2250,7 @@ Future main(List arguments) async {
Progress progress = new Progress(component.fileCount);
system.File outFile = new system.File(
- path.join(argResults['out'], 'licenses_${component.io.name}'));
+ path.join(argResults['out'], 'licenses_${component.name}'));
system.IOSink sink = outFile.openWrite();
if (signature != null)
sink.writeln('Signature: $signature\n');
@@ -2266,7 +2266,7 @@ Future main(List arguments) async {
// contain any state left over from previous components.
clearLicenseRegistry();
componentRoot = new RepositoryRoot(rootDirectory).subdirectories.firstWhere(
- (RepositoryDirectory dir) => dir.io.name == component.io.name
+ (RepositoryDirectory dir) => dir.name == component.name
);
}
List licenses = new Set.from(