forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename sky -> flutter in shell (flutter#3293)
- Loading branch information
1 parent
cdb18a5
commit 6794bc2
Showing
19 changed files
with
248 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
shell/platform/android/io/flutter/app/FlutterActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
shell/platform/android/io/flutter/app/FlutterApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.