Skip to content

Commit

Permalink
rename sky -> flutter in shell (flutter#3293)
Browse files Browse the repository at this point in the history
  • Loading branch information
collinjackson authored Dec 6, 2016
1 parent cdb18a5 commit 6794bc2
Show file tree
Hide file tree
Showing 19 changed files with 248 additions and 205 deletions.
6 changes: 3 additions & 3 deletions shell/platform/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
]
Expand Down
145 changes: 145 additions & 0 deletions shell/platform/android/io/flutter/app/FlutterActivity.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
21 changes: 21 additions & 0 deletions shell/platform/android/io/flutter/app/FlutterApplication.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
140 changes: 4 additions & 136 deletions shell/platform/android/org/domokit/sky/shell/SkyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
16 changes: 5 additions & 11 deletions shell/platform/android/org/domokit/sky/shell/SkyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
Loading

0 comments on commit 6794bc2

Please sign in to comment.