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