Make a pass through all the embedding javadocs (flutter/engine#17109)

This commit is contained in:
xster
2020-03-13 16:34:34 -07:00
committed by GitHub
parent 489e5252c6
commit ea2cb63687
9 changed files with 61 additions and 30 deletions

View File

@@ -15,7 +15,13 @@ import io.flutter.plugin.common.PluginRegistry;
import io.flutter.view.FlutterNativeView;
import io.flutter.view.FlutterView;
/** Base class for activities that use Flutter. */
/**
* Deprecated base class for activities that use Flutter.
*
* <p>Deprecation: {@link io.flutter.embedding.android.FlutterActivity} is the new API that now
* replaces this class. See https://flutter.dev/go/android-project-migration for more migration
* details.
*/
public class FlutterActivity extends Activity
implements FlutterView.Provider, PluginRegistry, ViewFactory {
private static final String TAG = "FlutterActivity";

View File

@@ -12,6 +12,9 @@ import io.flutter.view.FlutterMain;
/**
* Flutter implementation of {@link android.app.Application}, managing application-level global
* initializations.
*
* <p>Using this {@link android.app.Application} is not required when using APIs in the package
* {@code io.flutter.embedding.android} since they self-initialize on first use.
*/
public class FlutterApplication extends Application {
@Override

View File

@@ -21,6 +21,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/// This class is now deprecated. See https://flutter.dev/go/android-project-migration for
/// migration instructions.
public class FlutterPluginRegistry
implements PluginRegistry,
PluginRegistry.RequestPermissionsResultListener,

View File

@@ -51,11 +51,27 @@ import java.lang.reflect.Method;
* <p>{@code FlutterActivity} is the simplest and most direct way to integrate Flutter within an
* Android app.
*
* <p><strong>FlutterActivity responsibilities</strong>
*
* <p>{@code FlutterActivity} maintains the following responsibilities:
*
* <ul>
* <li>Displays an Android launch screen.
* <li>Displays a Flutter splash screen.
* <li>Configures the status bar appearance.
* <li>Chooses the Dart execution app bundle path and entrypoint.
* <li>Chooses Flutter's initial route.
* <li>Renders {@code Activity} transparently, if desired.
* <li>Offers hooks for subclasses to provide and configure a {@link FlutterEngine}.
* </ul>
*
* <p><strong>Dart entrypoint, initial route, and app bundle path</strong>
*
* <p>The Dart entrypoint executed within this {@code Activity} is "main()" by default. To change
* the entrypoint that a {@code FlutterActivity} executes, subclass {@code FlutterActivity} and
* override {@link #getDartEntrypointFunctionName()}.
* override {@link #getDartEntrypointFunctionName()}. For non-main Dart entrypoints to not be
* tree-shaken away, you need to annotate those functions with {@code @pragma('vm:entry-point')} in
* Dart.
*
* <p>The Flutter route that is initially loaded within this {@code Activity} is "/". The initial
* route may be specified explicitly by passing the name of the route as a {@code String} in {@link
@@ -73,11 +89,8 @@ import java.lang.reflect.Method;
* <li>{@link #getInitialRoute()}
* </ul>
*
* <p>The Dart entrypoint and app bundle path are not supported as {@code Intent} parameters due to
* security concerns. If such configurations were exposed via {@code Intent}, then a {@code
* FlutterActivity} that is {@code exported} from your Android app would allow other apps to invoke
* arbitrary Dart entrypoints in your app by specifying different Dart entrypoints for your {@code
* FlutterActivity}. Therefore, these configurations are not available via {@code Intent}.
* <p>The Dart entrypoint and app bundle path are not supported as {@code Intent} parameters since
* your Dart library entrypoints are your private APIs and Intents are invocable by other processes.
*
* <p><strong>Using a cached FlutterEngine</strong>
*
@@ -85,8 +98,10 @@ import java.lang.reflect.Method;
* new one. Use {@link #withCachedEngine(String)} to build a {@code FlutterActivity} {@code Intent}
* that is configured to use an existing, cached {@link FlutterEngine}. {@link
* io.flutter.embedding.engine.FlutterEngineCache} is the cache that is used to obtain a given
* cached {@link FlutterEngine}. An {@code IllegalStateException} will be thrown if a cached engine
* is requested but does not exist in the cache.
* cached {@link FlutterEngine}. You must create and put a {@link FlutterEngine} into the {@link
* io.flutter.embedding.engine.FlutterEngineCache} yourself before using the {@link
* #withCachedEngine(String)} builder. An {@code IllegalStateException} will be thrown if a cached
* engine is requested but does not exist in the cache.
*
* <p>When using a cached {@link FlutterEngine}, that {@link FlutterEngine} should already be
* executing Dart code, which means that the Dart entrypoint and initial route have already been
@@ -105,6 +120,9 @@ import java.lang.reflect.Method;
* <li>When you are unsure when/if you will need to display a Flutter experience.
* </ul>
*
* <p>See https://flutter.dev/docs/development/add-to-app/performance for additional performance
* explorations on engine loading.
*
* <p>The following illustrates how to pre-warm and cache a {@link FlutterEngine}:
*
* <pre>{@code
@@ -126,20 +144,6 @@ import java.lang.reflect.Method;
* FlutterView}. Using a {@link FlutterView} requires forwarding some calls from an {@code
* Activity}, as well as forwarding lifecycle calls from an {@code Activity} or a {@code Fragment}.
*
* <p><strong>FlutterActivity responsibilities</strong>
*
* <p>{@code FlutterActivity} maintains the following responsibilities:
*
* <ul>
* <li>Displays an Android launch screen.
* <li>Displays a Flutter splash screen.
* <li>Configures the status bar appearance.
* <li>Chooses the Dart execution app bundle path and entrypoint.
* <li>Chooses Flutter's initial route.
* <li>Renders {@code Activity} transparently, if desired.
* <li>Offers hooks for subclasses to provide and configure a {@link FlutterEngine}.
* </ul>
*
* <p><strong>Launch Screen and Splash Screen</strong>
*
* <p>{@code FlutterActivity} supports the display of an Android "launch screen" as well as a
@@ -196,8 +200,12 @@ public class FlutterActivity extends Activity
private static final String TAG = "FlutterActivity";
/**
* Creates an {@link Intent} that launches a {@code FlutterActivity}, which executes a {@code
* main()} Dart entrypoint, and displays the "/" route as Flutter's initial route.
* Creates an {@link Intent} that launches a {@code FlutterActivity}, which creates a {@link
* FlutterEngine} that executes a {@code main()} Dart entrypoint, and displays the "/" route as
* Flutter's initial route.
*
* <p>Consider using the {@link #withCachedEngine(String)} {@link Intent} builder to control when
* the {@link FlutterEngine} should be created in your application.
*/
@NonNull
public static Intent createDefaultIntent(@NonNull Context launchContext) {

View File

@@ -44,7 +44,8 @@ import java.util.Set;
* interaction.
*
* <p>Multiple {@code FlutterEngine}s may exist, execute Dart code, and render UIs within a single
* Android app.
* Android app. Flutter at this point makes no guarantees on the performance of running multiple
* engines. Use at your own risk. See https://github.com/flutter/flutter/issues/37644 for details.
*
* <p>To start running Dart and/or Flutter within this {@code FlutterEngine}, get a reference to
* this engine's {@link DartExecutor} and then use {@link

View File

@@ -26,8 +26,7 @@ import java.nio.ByteBuffer;
*
* <p>To specify a Dart callback to execute, use a {@link DartCallback}. A given Dart callback must
* be registered with the Dart VM to be invoked by a {@link DartExecutor}. To execute the callback,
* pass the {@link DartCallback} to {@link #executeDartCallback(DartCallback)}. TODO(mattcarroll):
* add a reference to docs about background/plugin execution
* pass the {@link DartCallback} to {@link #executeDartCallback(DartCallback)}.
*
* <p>Once started, a {@link DartExecutor} cannot be stopped. The associated Dart code will execute
* until it completes, or until the {@link io.flutter.embedding.engine.FlutterEngine} that owns this

View File

@@ -24,6 +24,9 @@ import io.flutter.view.TextureRegistry;
* registrant class is, again by default, called from the application's main {@link Activity}, which
* defaults to an instance of {@link io.flutter.app.FlutterActivity}, itself a {@link
* PluginRegistry}.
*
* <p>This class is now deprecated. See https://flutter.dev/go/android-project-migration for
* migration details.
*/
public interface PluginRegistry {
/**

View File

@@ -11,7 +11,11 @@ import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import io.flutter.embedding.engine.loader.FlutterLoader;
/** A class to intialize the Flutter engine. */
/**
* A legacy class to initialize the Flutter engine.
*
* <p>Replaced by {@link io.flutter.embedding.engine.loader.FlutterLoader}.
*/
public class FlutterMain {
public static class Settings {

View File

@@ -60,7 +60,12 @@ import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicLong;
/** An Android view containing a Flutter app. */
/**
* Deprecated Android view containing a Flutter app.
*
* <p>Deprecation: {@link io.flutter.embedding.android.FlutterView} is the new API that now replaces
* this class. See https://flutter.dev/go/android-project-migration for more migration details.
*/
public class FlutterView extends SurfaceView implements BinaryMessenger, TextureRegistry {
/**
* Interface for those objects that maintain and expose a reference to a {@code FlutterView} (such