Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Embedding PR22: Polish - FlutterActivity Intent factories, FlutterFragment control of render modes, FlutterSurfaceView transparent until rendering is ready. #8317

Conversation

matthew-carroll
Copy link
Contributor

Android Embedding PR22: Polish - FlutterActivity Intent factories, FlutterFragment control of render modes, FlutterSurfaceView transparent until rendering is ready.

…utterFragment control of render modes, FlutterSurfaceView transparent until rendering is ready.
Copy link
Contributor

@mklim mklim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java style LGTM

ensureFlutterFragmentCreated();
}

private void configureStatusBarForFullscreenFlutterExperience() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional, subjective: Consider using guard clauses to reduce nesting.

https://testing.googleblog.com/2017/06/code-health-reduce-nesting-reduce.html

On another note though is it OK that we're not executing anything on older SDKs? Is the UI going to still render correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think older Android versions always have a black status bar.

* @param renderMode render Flutter either as a {@link FlutterView.RenderMode#surface} or a
* {@link FlutterView.RenderMode#texture}. Use {@code texture} for situations
* where this {@code FlutterFragment} might have content on top of it, such as
* a drawer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It's hard to get into the details a ton in just a line or two here but as is this isn't letting people know that using texture most likely comes with a huge performance cost. I'd probably rephrase to something along the lines of "Use {@code texture} when you're willing and able to sacrifice performance to have this {@code FlutterFragment} interleave with other Android views. {@code surface} is a much more performant default, but won't composite with complicated View hierarchies." Exact wording doesn't matter much to me but I think a really rough summary of the pros/cons would be worth it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

*/
@NonNull
protected FlutterView.RenderMode getRenderMode() {
String renderModeName = getArguments().getString(ARG_FLUTTERVIEW_RENDER_MODE, null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subjective, nit: If you set the default value here to FlutterView.RenderMode.surface.toString() you could have the next statement consistently return without needing a null check and ternary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@matthew-carroll
Copy link
Contributor Author

@jason-simmons @mklim @mjohnsullivan @tvolkert I just pushed a commit that converts FlutterActivity and FlutterFragment factories to builders for brevity and future expansion options.

@matthew-carroll matthew-carroll merged commit 7620056 into flutter:master Mar 27, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 27, 2019
…ries, FlutterFragment control of render modes, FlutterSurfaceView transparent until rendering is ready. (flutter/engine#8317)
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Mar 28, 2019
flutter/engine@3a3f707...7620056

git log 3a3f707..7620056 --no-merges --oneline
7620056 Android Embedding PR22: Polish - FlutterActivity Intent factories, FlutterFragment control of render modes, FlutterSurfaceView transparent until rendering is ready. (flutter/engine#8317)
6bd697d Fix "PointerEvent" flow end event (flutter/engine#8319)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff (bmparr@google.com), and stop
the roller if necessary.
* Builder to create an {@code Intent} that launches a {@code FlutterActivity} with the
* desired configuration.
*/
public static class IntentBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

(Google's [internal] "Effective Java" guide, Item 19: "Design and document for inheritance or else prohibit it")

*
* @return a new {@link FlutterFragment}
* To create a {@code FlutterFragment} with default {@code arguments}, invoke {@code build()}
* immeidately:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling

flutterShellArgs
);
frag.setArguments(args);
public static class Builder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

* to {@link FlutterMain#findAppBundlePath(Context)}
*/
@NonNull
public Builder appBundlePath(@NonNull String appBundlePath) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to say this is @Nullable?

I don't feel strongly either way - the argument in favor of @NonNull is that since it defaults to null, there's no reason to call this with a null value. But otoh, it wouldn't hurt either...

* Any special configuration arguments for the Flutter engine
*/
@NonNull
public Builder flutterShellArgs(@NonNull FlutterShellArgs shellArgs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here too

* Any special configuration arguments for the Flutter engine
*/
@NonNull
public Builder flutterShellArgs(@NonNull FlutterShellArgs shellArgs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: since the values we allow for shell args are well defined, I'd consider making the supported args in FlutterShellArgs an enum rather than Strings. Something like:

public final class FlutterShellArgs {
  public static final enum Argument {
    /**
     * <documentation>
     */
    TRACE_STARTUP("trace-startup"),

    /**
     * <documentation>
     */
    START_PAUSED("start-paused"),

    // More supported values here...

    /**
     * <documentation>
     */
    VERBOSE_LOGGING("verbose-logging");

    /**
     * The intent key. (more documentation...)
     */
    public final String key;

    /**
     * The flag that's passed to the Flutter shell.
     */
    public final String value;

    private Argument(String key) {
      this.key = key;
      value = "--" + key;
    }
  }

  @NonNull
  public static FlutterShelArgs fromIntent(@NonNull Intent intent) {
    ...

    if (intent.getBooleanExtra(Argument.TRACE_STARTUP.key, false)) {
      args.add(Argument.TRACE_STARTUP.value);
    }

    ...
  }
}

Also, is there any reason for FlutterShellArgs to be mutable?

RBogie pushed a commit to RBogie/flutter-engine that referenced this pull request Apr 8, 2019
…utterFragment control of render modes, FlutterSurfaceView transparent until rendering is ready. (flutter#8317)
RBogie added a commit to RBogie/flutter-engine that referenced this pull request Apr 8, 2019
…ries, FlutterFragment control of render modes, FlutterSurfaceView transparent until rendering is ready. (flutter#8317)"

This reverts commit 75a33f9.
RBogie added a commit to RBogie/flutter-engine that referenced this pull request Apr 8, 2019
…ries, FlutterFragment control of render modes, FlutterSurfaceView transparent until rendering is ready. (flutter#8317)"

This reverts commit 75a33f9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants