Commit 51c71940 authored by Adam Barth's avatar Adam Barth

Add SetRequestedOrientation to Activity service

Fixes #743
parent e95aee27
...@@ -135,8 +135,8 @@ class AddressBookApp extends App { ...@@ -135,8 +135,8 @@ class AddressBookApp extends App {
data: theme, data: theme,
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: typography.error, // if you see this, you've forgotten to correctly configure the text style! style: typography.error, // if you see this, you've forgotten to correctly configure the text style!
child: new TaskDescription( child: new Title(
label: 'Address Book', title: 'Address Book',
child: new Navigator(_navigationState) child: new Navigator(_navigationState)
) )
) )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:sky/mojo/activity.dart' as activity; import 'package:sky/mojo/activity.dart';
import 'package:sky/mojo/asset_bundle.dart'; import 'package:sky/mojo/asset_bundle.dart';
import 'package:sky/painting/box_painter.dart'; import 'package:sky/painting/box_painter.dart';
import 'package:sky/theme/colors.dart' as colors; import 'package:sky/theme/colors.dart' as colors;
...@@ -25,17 +25,17 @@ EventDisposition launch(String relativeUrl, String bundle) { ...@@ -25,17 +25,17 @@ EventDisposition launch(String relativeUrl, String bundle) {
Uri base = rootBundle == null ? Uri.base : productionBase; Uri base = rootBundle == null ? Uri.base : productionBase;
Uri url = base.resolve(relativeUrl); Uri url = base.resolve(relativeUrl);
activity.ComponentName component = new activity.ComponentName() ComponentName component = new ComponentName()
..packageName = 'org.domokit.sky.demo' ..packageName = 'org.domokit.sky.demo'
..className = 'org.domokit.sky.demo.SkyDemoActivity'; ..className = 'org.domokit.sky.demo.SkyDemoActivity';
activity.Intent intent = new activity.Intent() Intent intent = new Intent()
..action = 'android.intent.action.VIEW' ..action = 'android.intent.action.VIEW'
..component = component ..component = component
..flags = activity.MULTIPLE_TASK | activity.NEW_DOCUMENT ..flags = MULTIPLE_TASK | NEW_DOCUMENT
..url = url.toString(); ..url = url.toString();
if (bundle != null) { if (bundle != null) {
activity.StringExtra extra = new activity.StringExtra() StringExtra extra = new StringExtra()
..name = 'bundleName' ..name = 'bundleName'
..value = bundle; ..value = bundle;
intent.stringExtras = [extra]; intent.stringExtras = [extra];
...@@ -191,8 +191,8 @@ class SkyHome extends App { ...@@ -191,8 +191,8 @@ class SkyHome extends App {
brightness: ThemeBrightness.light, brightness: ThemeBrightness.light,
primarySwatch: colors.Teal primarySwatch: colors.Teal
), ),
child: new TaskDescription( child: new Title(
label: 'Sky Demos', title: 'Sky Demos',
child: new Scaffold( child: new Scaffold(
toolbar: new ToolBar(center: new Text('Sky Demos')), toolbar: new ToolBar(center: new Text('Sky Demos')),
body: new Material( body: new Material(
......
...@@ -171,8 +171,8 @@ class FitnessApp extends App { ...@@ -171,8 +171,8 @@ class FitnessApp extends App {
primarySwatch: colors.Indigo, primarySwatch: colors.Indigo,
accentColor: colors.PinkAccent[200] accentColor: colors.PinkAccent[200]
), ),
child: new TaskDescription( child: new Title(
label: 'Fitness', title: 'Fitness',
child: new Navigator(_navigationState) child: new Navigator(_navigationState)
) )
); );
......
...@@ -12,7 +12,7 @@ import 'package:sky/widgets/basic.dart'; ...@@ -12,7 +12,7 @@ import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/button_base.dart'; import 'package:sky/widgets/button_base.dart';
import 'package:sky/widgets/navigator.dart'; import 'package:sky/widgets/navigator.dart';
import 'package:sky/widgets/framework.dart'; import 'package:sky/widgets/framework.dart';
import 'package:sky/widgets/task_description.dart'; import 'package:sky/widgets/title.dart';
import 'package:sky/widgets/theme.dart'; import 'package:sky/widgets/theme.dart';
import 'game_demo.dart'; import 'game_demo.dart';
...@@ -104,8 +104,8 @@ class GameDemoApp extends App { ...@@ -104,8 +104,8 @@ class GameDemoApp extends App {
return new Theme( return new Theme(
data: theme, data: theme,
child: new TaskDescription( child: new Title(
label: 'Asteroids', title: 'Asteroids',
child: new Navigator(_navigationState) child: new Navigator(_navigationState)
) )
); );
......
...@@ -6,8 +6,7 @@ import 'package:sky/mojo/asset_bundle.dart'; ...@@ -6,8 +6,7 @@ import 'package:sky/mojo/asset_bundle.dart';
import 'package:sky/rendering/object.dart'; import 'package:sky/rendering/object.dart';
import 'package:sky/theme/colors.dart' as colors; import 'package:sky/theme/colors.dart' as colors;
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/task_description.dart'; import 'package:sky/widgets.dart';
import 'package:sky/widgets/theme.dart';
AssetBundle _initBundle() { AssetBundle _initBundle() {
if (rootBundle != null) if (rootBundle != null)
...@@ -45,8 +44,8 @@ class TestDrawAtlasApp extends App { ...@@ -45,8 +44,8 @@ class TestDrawAtlasApp extends App {
return new Theme( return new Theme(
data: theme, data: theme,
child: new TaskDescription( child: new Title(
label: 'Test drawAtlas', title: 'Test drawAtlas',
child: new SpriteWidget( child: new SpriteWidget(
new TestDrawAtlas(), new TestDrawAtlas(),
SpriteBoxTransformMode.fixedWidth SpriteBoxTransformMode.fixedWidth
......
...@@ -4,9 +4,7 @@ import 'dart:math' as math; ...@@ -4,9 +4,7 @@ import 'dart:math' as math;
import 'package:sky/mojo/asset_bundle.dart'; import 'package:sky/mojo/asset_bundle.dart';
import 'package:sky/rendering/object.dart'; import 'package:sky/rendering/object.dart';
import 'package:sky/theme/colors.dart' as colors; import 'package:sky/theme/colors.dart' as colors;
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets.dart';
import 'package:sky/widgets/task_description.dart';
import 'package:sky/widgets/theme.dart';
import 'lib/sprites.dart'; import 'lib/sprites.dart';
...@@ -46,8 +44,8 @@ class TestApp extends App { ...@@ -46,8 +44,8 @@ class TestApp extends App {
return new Theme( return new Theme(
data: theme, data: theme,
child: new TaskDescription( child: new Title(
label: 'Test Sprite Performance', title: 'Test Sprite Performance',
child: new SpriteWidget(new TestPerformance()) child: new SpriteWidget(new TestPerformance())
) )
); );
......
...@@ -183,8 +183,8 @@ class MineDiggerApp extends App { ...@@ -183,8 +183,8 @@ class MineDiggerApp extends App {
Widget build() { Widget build() {
// We build the board before we build the toolbar because we compute the win state during build step. // We build the board before we build the toolbar because we compute the win state during build step.
Widget board = buildBoard(); Widget board = buildBoard();
return new TaskDescription( return new Title(
label: 'Mine Digger', title: 'Mine Digger',
child: new Scaffold( child: new Scaffold(
toolbar: buildToolBar(), toolbar: buildToolBar(),
body: new Container( body: new Container(
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import 'dart:sky'; import 'dart:sky';
import 'dart:math' as math; import 'dart:math' as math;
import 'package:sky/mojo/activity.dart' as activity; import 'package:sky/mojo/activity.dart';
import 'package:sky/mojo/net/image_cache.dart' as image_cache; import 'package:sky/mojo/net/image_cache.dart' as image_cache;
import 'package:sky/rendering.dart'; import 'package:sky/rendering.dart';
...@@ -98,7 +98,7 @@ Pancetta meatball tongue tenderloin rump tail jowl boudin."""; ...@@ -98,7 +98,7 @@ Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
child: row child: row
); );
activity.updateTaskDescription('Interactive Flex', topColor); updateTaskDescription('Interactive Flex', topColor);
new SkyBinding(root: root); new SkyBinding(root: root);
view.setEventCallback(handleEvent); view.setEventCallback(handleEvent);
} }
...@@ -95,8 +95,8 @@ class StocksApp extends App { ...@@ -95,8 +95,8 @@ class StocksApp extends App {
data: theme, data: theme,
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: typography.error, // if you see this, you've forgotten to correctly configure the text style! style: typography.error, // if you see this, you've forgotten to correctly configure the text style!
child: new TaskDescription( child: new Title(
label: 'Stocks', title: 'Stocks',
child: new Navigator(_navigationState) child: new Navigator(_navigationState)
) )
) )
......
...@@ -117,8 +117,8 @@ class CardCollectionApp extends App { ...@@ -117,8 +117,8 @@ class CardCollectionApp extends App {
primarySwatch: colors.Blue, primarySwatch: colors.Blue,
accentColor: colors.RedAccent[200] accentColor: colors.RedAccent[200]
), ),
child: new TaskDescription( child: new Title(
label: 'Cards', title: 'Cards',
child: new Scaffold( child: new Scaffold(
toolbar: new ToolBar(center: new Text('Swipe Away')), toolbar: new ToolBar(center: new Text('Swipe Away')),
body: cardCollection body: cardCollection
......
...@@ -21,7 +21,7 @@ class EnsureVisibleApp extends App { ...@@ -21,7 +21,7 @@ class EnsureVisibleApp extends App {
const TextStyle(color: colors.white, fontSize: 18.0, fontWeight: bold); const TextStyle(color: colors.white, fontSize: 18.0, fontWeight: bold);
static const TextStyle selectedCardLabelStyle = static const TextStyle selectedCardLabelStyle =
const TextStyle(color: white, fontSize: 24.0, fontWeight: bold); const TextStyle(color: colors.white, fontSize: 24.0, fontWeight: bold);
List<CardModel> cardModels; List<CardModel> cardModels;
BlockViewportLayoutState layoutState = new BlockViewportLayoutState(); BlockViewportLayoutState layoutState = new BlockViewportLayoutState();
...@@ -89,8 +89,8 @@ class EnsureVisibleApp extends App { ...@@ -89,8 +89,8 @@ class EnsureVisibleApp extends App {
primarySwatch: colors.Blue, primarySwatch: colors.Blue,
accentColor: colors.RedAccent[200] accentColor: colors.RedAccent[200]
), ),
child: new TaskDescription( child: new Title(
label: 'Cards', title: 'Cards',
child: new Scaffold( child: new Scaffold(
toolbar: new ToolBar(center: new Text('Tap a Card')), toolbar: new ToolBar(center: new Text('Tap a Card')),
body: cardCollection body: cardCollection
......
...@@ -167,7 +167,7 @@ class OverlayGeometryApp extends App { ...@@ -167,7 +167,7 @@ class OverlayGeometryApp extends App {
primarySwatch: colors.Blue, primarySwatch: colors.Blue,
accentColor: colors.RedAccent[200] accentColor: colors.RedAccent[200]
), ),
child: new TaskDescription(label: 'Cards', child: new Stack(layers)) child: new Title(title: 'Cards', child: new Stack(layers))
) )
); );
} }
......
...@@ -3,17 +3,8 @@ ...@@ -3,17 +3,8 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:sky/base/lerp.dart'; import 'package:sky/base/lerp.dart';
import 'package:sky/painting/text_style.dart';
import 'package:sky/theme/colors.dart'; import 'package:sky/theme/colors.dart';
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets.dart';
import 'package:sky/widgets/card.dart';
import 'package:sky/widgets/icon.dart';
import 'package:sky/widgets/scrollable.dart';
import 'package:sky/widgets/scaffold.dart';
import 'package:sky/widgets/theme.dart';
import 'package:sky/widgets/tool_bar.dart';
import 'package:sky/widgets/framework.dart';
import 'package:sky/widgets/task_description.dart';
class CardModel { class CardModel {
CardModel(this.value, this.size, this.color); CardModel(this.value, this.size, this.color);
...@@ -105,8 +96,8 @@ class PageableListApp extends App { ...@@ -105,8 +96,8 @@ class PageableListApp extends App {
primarySwatch: Blue, primarySwatch: Blue,
accentColor: RedAccent[200] accentColor: RedAccent[200]
), ),
child: new TaskDescription( child: new Title(
label: 'PageableList', title: 'PageableList',
child: new Scaffold( child: new Scaffold(
toolbar: new Listener( toolbar: new Listener(
onGestureTap: handleToolbarTap, onGestureTap: handleToolbarTap,
......
...@@ -98,8 +98,8 @@ class ProgressIndicatorApp extends App { ...@@ -98,8 +98,8 @@ class ProgressIndicatorApp extends App {
primarySwatch: colors.Blue, primarySwatch: colors.Blue,
accentColor: colors.RedAccent[200] accentColor: colors.RedAccent[200]
), ),
child: new TaskDescription( child: new Title(
label: 'Cards', title: 'Cards',
child: new Scaffold( child: new Scaffold(
toolbar: new ToolBar(center: new Text('Progress Indicators')), toolbar: new ToolBar(center: new Text('Progress Indicators')),
body: body body: body
......
...@@ -122,8 +122,8 @@ class SectorApp extends App { ...@@ -122,8 +122,8 @@ class SectorApp extends App {
Widget build() { Widget build() {
return new Theme( return new Theme(
data: new ThemeData.light(), data: new ThemeData.light(),
child: new TaskDescription( child: new Title(
label: 'Sector Layout', title: 'Sector Layout',
child: new Scaffold( child: new Scaffold(
toolbar: new ToolBar( toolbar: new ToolBar(
center: new Text('Sector Layout in a Widget Tree') center: new Text('Sector Layout in a Widget Tree')
......
...@@ -19,17 +19,18 @@ const int NEW_DOCUMENT = 0x00080000; ...@@ -19,17 +19,18 @@ const int NEW_DOCUMENT = 0x00080000;
const int NEW_TASK = 0x10000000; const int NEW_TASK = 0x10000000;
const int MULTIPLE_TASK = 0x08000000; const int MULTIPLE_TASK = 0x08000000;
ActivityProxy _initActivity() { ActivityProxy _initActivityProxy() {
ActivityProxy activity = new ActivityProxy.unbound(); ActivityProxy activity = new ActivityProxy.unbound();
shell.requestService('mojo:sky_viewer', activity); shell.requestService('mojo:sky_viewer', activity);
return activity; return activity;
} }
final ActivityProxy _activity = _initActivity(); final ActivityProxy _activityProxy = _initActivityProxy();
final Activity activity = _activityProxy.ptr;
UserFeedbackProxy _initUserFeedbackProxy() { UserFeedbackProxy _initUserFeedbackProxy() {
UserFeedbackProxy proxy = new UserFeedbackProxy.unbound(); UserFeedbackProxy proxy = new UserFeedbackProxy.unbound();
_activity.ptr.getUserFeedback(proxy); _activityProxy.ptr.getUserFeedback(proxy);
return proxy; return proxy;
} }
...@@ -39,16 +40,6 @@ final UserFeedback userFeedback = _userFeedbackProxy.ptr; ...@@ -39,16 +40,6 @@ final UserFeedback userFeedback = _userFeedbackProxy.ptr;
Color _cachedPrimaryColor; Color _cachedPrimaryColor;
String _cachedLabel; String _cachedLabel;
/// Ends the current activity.
void finishCurrentActivity() {
_activity.ptr.finishCurrentActivity();
}
/// Asks the Android ActivityManager to start a new Intent-based Activity.
void startActivity(Intent intent) {
_activity.ptr.startActivity(intent);
}
/// Sets the TaskDescription for the current Activity /// Sets the TaskDescription for the current Activity
void updateTaskDescription(String label, Color color) { void updateTaskDescription(String label, Color color) {
if (_cachedPrimaryColor == color && _cachedLabel == label) if (_cachedPrimaryColor == color && _cachedLabel == label)
...@@ -61,18 +52,8 @@ void updateTaskDescription(String label, Color color) { ...@@ -61,18 +52,8 @@ void updateTaskDescription(String label, Color color) {
..label = label ..label = label
..primaryColor = (color != null ? color.value : null); ..primaryColor = (color != null ? color.value : null);
_activity.ptr.setTaskDescription(description); _activityProxy.ptr.setTaskDescription(description);
} }
int _cachedSystemUiVisibility = SystemUIVisibility_STANDARD; Future<String> getFilesDir() async => (await _activityProxy.ptr.getFilesDir()).path;
Future<String> getCacheDir() async => (await _activityProxy.ptr.getCacheDir()).path;
void setSystemUiVisibility(int visibility) {
if (_cachedSystemUiVisibility == visibility)
return;
_cachedSystemUiVisibility = visibility;
_activity.ptr.setSystemUiVisibility(visibility);
}
Future<String> getFilesDir() async => (await _activity.ptr.getFilesDir()).path;
Future<String> getCacheDir() async => (await _activity.ptr.getCacheDir()).path;
...@@ -42,8 +42,8 @@ export 'widgets/scrollable.dart'; ...@@ -42,8 +42,8 @@ export 'widgets/scrollable.dart';
export 'widgets/snack_bar.dart'; export 'widgets/snack_bar.dart';
export 'widgets/switch.dart'; export 'widgets/switch.dart';
export 'widgets/tabs.dart'; export 'widgets/tabs.dart';
export 'widgets/task_description.dart';
export 'widgets/theme.dart'; export 'widgets/theme.dart';
export 'widgets/title.dart';
export 'widgets/tool_bar.dart'; export 'widgets/tool_bar.dart';
export 'widgets/transitions.dart'; export 'widgets/transitions.dart';
......
...@@ -8,7 +8,7 @@ import 'dart:sky' as sky; ...@@ -8,7 +8,7 @@ import 'dart:sky' as sky;
import 'package:sky/base/hit_test.dart'; import 'package:sky/base/hit_test.dart';
import 'package:sky/base/scheduler.dart' as scheduler; import 'package:sky/base/scheduler.dart' as scheduler;
import 'package:sky/mojo/activity.dart' as activity; import 'package:sky/mojo/activity.dart';
import 'package:sky/rendering/box.dart'; import 'package:sky/rendering/box.dart';
import 'package:sky/rendering/object.dart'; import 'package:sky/rendering/object.dart';
import 'package:sky/rendering/sky_binding.dart'; import 'package:sky/rendering/sky_binding.dart';
......
// 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 'package:sky/mojo/activity.dart' as activity;
import 'package:sky/widgets/theme.dart';
import 'package:sky/widgets/framework.dart';
class TaskDescription extends Component {
TaskDescription({ this.label, this.child });
final Widget child;
final String label;
Widget build() {
activity.updateTaskDescription(label, Theme.of(this).primaryColor);
return child;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment