rename sky -> flutter in shell (flutter/engine#3293)

This commit is contained in:
Collin Jackson
2016-12-06 14:43:53 -08:00
committed by GitHub
parent 7764bbac05
commit 40f3877c23
18 changed files with 238 additions and 197 deletions

View File

@@ -3,18 +3,18 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.domokit.sky.shell" android:versionCode="1" android:versionName="0.0.1">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.flutter.app" android:versionCode="1" android:versionName="0.0.1">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
<application android:label="Sky Shell" android:name="SkyApplication" android:debuggable="true">
<application android:label="Flutter Shell" android:name="FlutterApplication" android:debuggable="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:hardwareAccelerated="true"
android:launchMode="standard"
android:name="SkyActivity"
android:name="FlutterActivity"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustResize">
<intent-filter>

View File

@@ -64,6 +64,8 @@ android_library("java") {
visibility = [ ":*" ]
java_files = [
"io/flutter/app/FlutterActivity.java",
"io/flutter/app/FlutterApplication.java",
"io/flutter/plugin/common/ActivityLifecycleListener.java",
"io/flutter/plugin/common/JSONMessageListener.java",
"io/flutter/plugin/editing/InputConnectionAdaptor.java",
@@ -76,6 +78,7 @@ android_library("java") {
"io/flutter/view/ResourceExtractor.java",
"io/flutter/view/ResourcePaths.java",
"io/flutter/view/VsyncWaiter.java",
# Deprecated classes provided for backwards compatibility
"org/domokit/sky/shell/SkyActivity.java",
"org/domokit/sky/shell/SkyApplication.java",
]

View File

@@ -0,0 +1,145 @@
// Copyright 2015 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.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import io.flutter.plugin.platform.PlatformPlugin;
import io.flutter.view.FlutterMain;
import io.flutter.view.FlutterView;
import java.util.ArrayList;
import org.chromium.base.TraceEvent;
/**
* Base class for activities that use Flutter.
*/
public class FlutterActivity extends Activity {
private FlutterView mView;
private String[] getArgsFromIntent(Intent intent) {
// Before adding more entries to this list, consider that arbitrary
// Android applications can generate intents with extra data and that
// there are many security-sensitive args in the binary.
ArrayList<String> args = new ArrayList<String>();
if (intent.getBooleanExtra("trace-startup", false)) {
args.add("--trace-startup");
}
if (intent.getBooleanExtra("start-paused", false)) {
args.add("--start-paused");
}
if (intent.getBooleanExtra("enable-dart-profiling", false)) {
args.add("--enable-dart-profiling");
}
if (!args.isEmpty()) {
String[] argsArray = new String[args.size()];
return args.toArray(argsArray);
}
return null;
}
/**
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(0x40000000);
window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
}
String[] args = getArgsFromIntent(getIntent());
FlutterMain.ensureInitializationComplete(getApplicationContext(), args);
mView = new FlutterView(this);
setContentView(mView);
onFlutterReady();
}
/**
* @see android.app.Activity#onDestroy()
*/
@Override
protected void onDestroy() {
if (mView != null) {
mView.destroy();
}
super.onDestroy();
}
@Override
public void onBackPressed() {
if (mView != null) {
mView.popRoute();
return;
}
super.onBackPressed();
}
@Override
protected void onPause() {
super.onPause();
if (mView != null) {
mView.onPause();
}
}
@Override
protected void onPostResume() {
super.onPostResume();
if (mView != null) {
mView.onPostResume();
}
}
/**
* Override this function to customize startup behavior.
*/
protected void onFlutterReady() {
TraceEvent.instant("FlutterActivity.onFlutterReady");
if (loadIntent(getIntent())) {
return;
}
String appBundlePath = FlutterMain.findAppBundlePath(getApplicationContext());
if (appBundlePath != null) {
mView.runFromBundle(appBundlePath, null);
return;
}
}
protected void onNewIntent(Intent intent) {
loadIntent(intent);
}
public boolean loadIntent(Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_RUN.equals(action)) {
String route = intent.getStringExtra("route");
String appBundlePath = intent.getDataString();
if (appBundlePath == null) {
// Fall back to the installation path if no bundle path
// was specified.
appBundlePath =
FlutterMain.findAppBundlePath(getApplicationContext());
}
mView.runFromBundle(appBundlePath,
intent.getStringExtra("snapshot"));
if (route != null)
mView.pushRoute(route);
return true;
}
return false;
}
}

View File

@@ -0,0 +1,21 @@
// Copyright 2015 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.app.Application;
import io.flutter.view.FlutterMain;
/**
* Flutter implementation of {@link android.app.Application}, managing
* application-level global initializations.
*/
public class FlutterApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
FlutterMain.startInitialization(this);
}
}

View File

@@ -4,143 +4,11 @@
package org.domokit.sky.shell;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import io.flutter.plugin.platform.PlatformPlugin;
import io.flutter.view.FlutterMain;
import io.flutter.view.FlutterView;
import java.util.ArrayList;
import org.chromium.base.TraceEvent;
import io.flutter.app.FlutterActivity;
/**
* Base class for activities that use Sky.
* Use io.flutter.app.FlutterActivity instead
* This class should be removed after Feb 2017
*/
public class SkyActivity extends Activity {
private FlutterView mView;
private String[] getArgsFromIntent(Intent intent) {
// Before adding more entries to this list, consider that arbitrary
// Android applications can generate intents with extra data and that
// there are many security-sensitive args in the binary.
ArrayList<String> args = new ArrayList<String>();
if (intent.getBooleanExtra("trace-startup", false)) {
args.add("--trace-startup");
}
if (intent.getBooleanExtra("start-paused", false)) {
args.add("--start-paused");
}
if (intent.getBooleanExtra("enable-dart-profiling", false)) {
args.add("--enable-dart-profiling");
}
if (!args.isEmpty()) {
String[] argsArray = new String[args.size()];
return args.toArray(argsArray);
}
return null;
}
/**
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(0x40000000);
window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
}
String[] args = getArgsFromIntent(getIntent());
FlutterMain.ensureInitializationComplete(getApplicationContext(), args);
mView = new FlutterView(this);
setContentView(mView);
onSkyReady();
}
/**
* @see android.app.Activity#onDestroy()
*/
@Override
protected void onDestroy() {
if (mView != null) {
mView.destroy();
}
// Do we need to shut down Sky too?
super.onDestroy();
}
@Override
public void onBackPressed() {
if (mView != null) {
mView.popRoute();
return;
}
super.onBackPressed();
}
@Override
protected void onPause() {
super.onPause();
if (mView != null) {
mView.onPause();
}
}
@Override
protected void onPostResume() {
super.onPostResume();
if (mView != null) {
mView.onPostResume();
}
}
/**
* Override this function to customize startup behavior.
*/
protected void onSkyReady() {
TraceEvent.instant("SkyActivity.onSkyReady");
if (loadIntent(getIntent())) {
return;
}
String appBundlePath = FlutterMain.findAppBundlePath(getApplicationContext());
if (appBundlePath != null) {
mView.runFromBundle(appBundlePath, null);
return;
}
}
protected void onNewIntent(Intent intent) {
loadIntent(intent);
}
public boolean loadIntent(Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_RUN.equals(action)) {
String route = intent.getStringExtra("route");
String appBundlePath = intent.getDataString();
if (appBundlePath == null) {
// Fall back to the installation path if no bundle path
// was specified.
appBundlePath =
FlutterMain.findAppBundlePath(getApplicationContext());
}
mView.runFromBundle(appBundlePath,
intent.getStringExtra("snapshot"));
if (route != null)
mView.pushRoute(route);
return true;
}
return false;
}
public class SkyActivity extends FlutterActivity {
}

View File

@@ -4,18 +4,12 @@
package org.domokit.sky.shell;
import android.app.Application;
import io.flutter.view.FlutterMain;
import io.flutter.app.FlutterApplication;
/**
* Sky implementation of {@link android.app.Application}, managing application-level global
* initializations.
* Use io.flutter.app.FlutterActivity instead
* This class should be removed after Feb 2017
*/
public class SkyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
FlutterMain.startInitialization(this);
}
@Deprecated
public class SkyApplication extends FlutterApplication {
}

View File

@@ -13,12 +13,12 @@ source_set("mac_desktop_platform") {
"main_mac.mm",
"platform_view_mac.h",
"platform_view_mac.mm",
"sky_app_delegate.h",
"sky_app_delegate.m",
"sky_application.h",
"sky_application.mm",
"sky_window.h",
"sky_window.mm",
"flutter_app_delegate.h",
"flutter_app_delegate.m",
"flutter_application.h",
"flutter_application.mm",
"flutter_window.h",
"flutter_window.mm",
"vsync_waiter_mac.cc",
"vsync_waiter_mac.h",
]
@@ -57,7 +57,7 @@ resource_copy_mac("mac_desktop_resources") {
mac_app("shell_application_bundle") {
app_name = "SkyShell"
info_plist = "Info.plist"
xibs = [ "sky_mac.xib" ]
xibs = [ "flutter_mac.xib" ]
deps = [
":mac_desktop_platform",

View File

@@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.domokit.sky</string>
<string>io.flutter</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
@@ -29,6 +29,6 @@
<key>NSMainNibFile</key>
<string>sky_mac</string>
<key>NSPrincipalClass</key>
<string>SkyApplication</string>
<string>FlutterApplication</string>
</dict>
</plist>

View File

@@ -0,0 +1,14 @@
// Copyright 2015 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.
#ifndef __SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_APP_DELEGATE__
#define __SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_APP_DELEGATE__
#import <Cocoa/Cocoa.h>
@interface FlutterAppDelegate : NSObject<NSApplicationDelegate>
@end
#endif /* defined(__SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_APP_DELEGATE__) */

View File

@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "sky_app_delegate.h"
#import "flutter_app_delegate.h"
@interface SkyAppDelegate ()
@interface FlutterAppDelegate ()
@property(assign) IBOutlet NSWindow* window;
@end
@implementation SkyAppDelegate
@implementation FlutterAppDelegate
@end

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef __SHELL_MAC_SKY_APPLICATION__
#define __SHELL_MAC_SKY_APPLICATION__
#ifndef __SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_APPLICATION__
#define __SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_APPLICATION__
#import <AppKit/AppKit.h>
@@ -12,7 +12,7 @@
// A specific subclass of NSApplication is necessary on Mac in order to
// interact correctly with the main runloop.
@interface SkyApplication : NSApplication<CrAppProtocol, CrAppControlProtocol>
@interface FlutterApplication : NSApplication<CrAppProtocol, CrAppControlProtocol>
@end
#endif /* defined(__SHELL_MAC_SKY_APPLICATION__) */
#endif /* defined(__SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_APPLICATION__) */

View File

@@ -2,24 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/darwin/desktop/sky_application.h"
#include "flutter/shell/platform/darwin/desktop/flutter_application.h"
#include "base/auto_reset.h"
#include "base/logging.h"
@implementation SkyApplication {
@implementation FlutterApplication {
BOOL handlingSendEvent_;
}
+ (void)initialize {
if (self == [SkyApplication class]) {
NSApplication* app = [SkyApplication sharedApplication];
if (self == [FlutterApplication class]) {
NSApplication* app = [FlutterApplication sharedApplication];
DCHECK([app conformsToProtocol:@protocol(CrAppControlProtocol)])
<< "Existing NSApp (class " << [[app className] UTF8String]
<< ") does not conform to required protocol.";
DCHECK(base::MessagePumpMac::UsingCrApp())
<< "MessagePumpMac::Create() was called before "
<< "+[SkyApplication initialize]";
<< "+[FlutterApplication initialize]";
}
}

View File

@@ -4,14 +4,14 @@
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SkyApplication">
<customObject id="-2" userLabel="File's Owner" customClass="FlutterApplication">
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="SkyAppDelegate">
<customObject id="Voe-Tx-rLC" customClass="FlutterAppDelegate">
<connections>
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
</connections>

View File

@@ -0,0 +1,14 @@
// Copyright 2015 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.
#ifndef __SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_WINDOW__
#define __SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_WINDOW__
#import <Cocoa/Cocoa.h>
@interface FlutterWindow : NSWindow
@end
#endif /* defined(__SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_WINDOW__) */

View File

@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "sky_window.h"
#import "flutter_window.h"
#include "flutter/common/threads.h"
#include "flutter/shell/gpu/gpu_surface_gl.h"
#include "flutter/shell/platform/darwin/desktop/platform_view_mac.h"
@interface SkyWindow ()<NSWindowDelegate>
@interface FlutterWindow ()<NSWindowDelegate>
@property(assign) IBOutlet NSOpenGLView* renderSurface;
@property(getter=isSurfaceSetup) BOOL surfaceSetup;
@@ -37,7 +37,7 @@ static inline blink::PointerData::Change PointerChangeFromNSEventPhase(
return blink::PointerData::Change::kCancel;
}
@implementation SkyWindow {
@implementation FlutterWindow {
std::unique_ptr<shell::PlatformViewMac> _platformView;
bool _mouseIsDown;
}
@@ -63,7 +63,7 @@ static inline blink::PointerData::Change PointerChangeFromNSEventPhase(
std::make_unique<shell::GPUSurfaceGL>(_platformView.get()));
}
// TODO(eseidel): This does not belong in sky_window!
// TODO(eseidel): This does not belong in flutter_window!
// Probably belongs in NSApplicationDelegate didFinishLaunching.
- (void)setupAndLoadDart {
_platformView->SetupAndLoadDart();

View File

@@ -11,7 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "flutter/shell/common/switches.h"
#include "flutter/shell/platform/darwin/common/platform_mac.h"
#include "flutter/shell/platform/darwin/desktop/sky_application.h"
#include "flutter/shell/platform/darwin/desktop/flutter_application.h"
#include "flutter/shell/testing/testing.h"
namespace shell {
@@ -30,7 +30,7 @@ void AttachMessageLoopToMainRunLoop(void) {
} // namespace shell
int main(int argc, const char* argv[]) {
[SkyApplication sharedApplication];
[FlutterApplication sharedApplication];
shell::PlatformMacMain(argc, argv, "", "");

View File

@@ -1,9 +0,0 @@
// Copyright 2015 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.
#import <Cocoa/Cocoa.h>
@interface SkyAppDelegate : NSObject<NSApplicationDelegate>
@end

View File

@@ -1,9 +0,0 @@
// Copyright 2015 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.
#import <Cocoa/Cocoa.h>
@interface SkyWindow : NSWindow
@end