Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1205)

Unified Diff: sky/examples/raw/launcher.dart

Issue 1187583002: Add the ability for Sky content to trigger Android intents (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/examples/raw/launcher.dart
diff --git a/sky/examples/raw/hello_world.dart b/sky/examples/raw/launcher.dart
similarity index 62%
copy from sky/examples/raw/hello_world.dart
copy to sky/examples/raw/launcher.dart
index 4264abf8990f0bee5c78ce2d5bad6f70456e9ee3..58341d184b1df9dd89a323f0fe5ac3ab460c972e 100644
--- a/sky/examples/raw/hello_world.dart
+++ b/sky/examples/raw/launcher.dart
@@ -5,6 +5,9 @@
import "dart:math";
import 'dart:sky';
+import 'package:sky/framework/shell.dart' as shell;
+import 'package:mojom/intents/intents.mojom.dart';
+
Picture draw(int a, int r, int g, int b) {
double width = view.width;
double height = view.height;
@@ -13,7 +16,7 @@ Picture draw(int a, int r, int g, int b) {
double radius = min(width, height) * 0.45;
Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b);
- recorder.drawCircle(width / 2, height / 2, radius, paint);
+ recorder.drawRect(new Rect.fromSize(new Size(width, height)), paint);
return recorder.endRecording();
}
@@ -25,8 +28,15 @@ bool handleEvent(Event event) {
}
if (event.type == "pointerup") {
- view.picture = draw(255, 0, 255, 0);
+ view.picture = draw(255, 255, 255, 0);
view.scheduleFrame();
+
+ ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound();
+ Intent intent = new Intent()
+ ..action = 'android.intent.action.VIEW'
+ ..url = 'sky://localhost:9888/sky/examples/raw/hello_world.dart';
+ shell.requestService(null, activityManager);
+ activityManager.ptr.startActivity(intent);
return true;
}
@@ -40,7 +50,7 @@ bool handleEvent(Event event) {
void main() {
print("Hello, world");
- view.picture = draw(255, 0, 255, 0);
+ view.picture = draw(255, 255, 255, 0);
view.scheduleFrame();
view.setEventCallback(handleEvent);

Powered by Google App Engine
This is Rietveld 408576698