+ All Categories
Home > Documents > text uri bitmap html.

text uri bitmap html.

Date post: 29-Mar-2015
Category:
Upload: unique-galen
View: 222 times
Download: 0 times
Share this document with a friend
Popular Tags:
38
1+1=3: Using app contracts to integrate with Windows 8 experiences Jaime Rodriguez Windows Evangelist 3-100
Transcript
Page 1: text uri bitmap html.

1+1=3: Using app contracts to integrate with Windows 8 experiencesJaime RodriguezWindows Evangelist3-100

Page 2: text uri bitmap html.

Reimagine connected apps

Page 3: text uri bitmap html.

Most apps have rich content that users want to..

Find and act upon Share Save or enhance in other apps Print Send to devices…

Page 4: text uri bitmap html.

Contracts are agreements between apps and the operating system to accomplish a common task in a manner.

consistent, easily accessible

Page 5: text uri bitmap html.

Windows 8 contracts

Share Search Settings Play To File Picker Cached file updater

Page 6: text uri bitmap html.

Contracts in action

Demo

Page 7: text uri bitmap html.

Windows does the heavy lifting, you focus on the scenario

Page 8: text uri bitmap html.

Share contract

Page 9: text uri bitmap html.

Sharing

Share source

Share target

Page 10: text uri bitmap html.

Sharing from source to target Source app Operating

system Share target app

Registers with the DataTransfer Manager

Receives event and fills DataPackage

User selects “Share”, active app is sent event

Filters list of Target Apps and Quicklinks

User selects Target App or Quicklink

Activated for sharing Activate Target as kind shareTarget Processes

DataPackage contents

Reports Complete DataPackage lives in source application

Completes async calls and returns

Page 11: text uri bitmap html.

//Step 1: Listen for DataTransferManager.datarequested var dtmns = Windows.ApplicationModel.DataTransfer.DataTransferManager; var dataTransferManager = dtmns.getForCurrentView(); dataTransferManager.addEventListener("datarequested", dataRequestHandler);

/* Step2: In datarequested handler, add title, description, and data in supported formats.*/

function dataRequestHandler ( e ) { var request = e.request;

request.data.properties.title = “Title is required” ;

request.data.properties.description = “Description is optional” ;

request.data.setText(“Hi mom!”);

}

Implementing share source

Page 12: text uri bitmap html.

Implementing share source

Demo

Page 13: text uri bitmap html.

//Step 1: Declare contract in app manifest

//Step 2: Handle app activation

//Step 3: Handle share operation

//Step 4: Create a QuickLink to return (Optional)

//Step 5: Report extended status and completion

Implementing share target

Page 14: text uri bitmap html.

<Extensions> <Extension Category="windows.shareTarget" StartPage="target.html">

<ShareTarget>

<DataFormat>text</DataFormat>

<DataFormat>uri</DataFormat>

<DataFormat>bitmap</DataFormat> <DataFormat>html</DataFormat>

</ShareTarget>

</Extension>

</Extensions>

Declaring share contract in app’s manifest

Page 15: text uri bitmap html.

//Step 2: Handle app activation

if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.shareTarget) { //Step 3: Handle share operation shareOperation = eventObject.detail.shareOperation; if (shareOperation.data.contains(

Windows.ApplicationModel.DataTransfer.StandardDataFormats.text)) {

shareOperation.data.getTextAsync().done(function (text) {

displayContent ("Text: ", text, false); }); }

//Step 4: Return a QuickLink object (Optional) var quickLink = new Windows.ApplicationModel.DataTransfer.ShareTarget.QuickLink(); quickLink.id = “uniqueId”; quickLink.title = “Title for this link” ; quickLink.supportedDataFormats.replaceAll([dataFormats.text, dataFormats.uri]);

//Step 5: Report extended status and completion shareOperation.reportCompleted(quickLink);

}

Implementing share target

Page 16: text uri bitmap html.

Implementing share target

Code walk-through

Page 17: text uri bitmap html.

Sharing tips:

SourceInclude as many data formats as appropriate

Leverage app’s context

TargetLeverage the Visual Studio template

Build a beautiful, lightweight share experience

Report completion & progress

Return QuickLinks

You can use Visual Studio to debug Share operations

Page 18: text uri bitmap html.

Answers to share FAQs

1You can’t control what apps you share with. You can control the formats.

You can configure metadata from a website on share.

2No extra work required for long-running share operations

Look into BackgroundUploader class if you want to transfer the file during share

3Quicklinks are not roamed and they are not preconfigured.

QuickLink image can (and should) be different from your app icon

Page 19: text uri bitmap html.

Search contract

Page 20: text uri bitmap html.

Search contract makes your app searchable from anywhere in the system.

Page 21: text uri bitmap html.

Search anatomy

1. Search box (scoped)

2. Apps that implement search contract

3. Query suggestions provided by foreground app

4. Result suggestions

4

1

3

2

Page 22: text uri bitmap html.

//Step 1: Declare search in the manifest

//Step 2: Check app activation and implement actual search

WinJS.Application.addEventListener("activated", function (args) { /*.. */

if (args.detail.kind === appModel.Activation.ActivationKind.search)

return nav.navigate(searchPageURI, { queryText: args.detail.queryText }); }

// Step 3: Implement querysubmitted handler

Windows.ApplicationModel;.Search.SearchPane.getForCurrentView().onquerysubmitted = function (args) { nav.navigate(searchPageURI, args); };

//Step 4: [Recommended] Implement Suggestions Requested

appModel.Search.SearchPane.getForCurrentView().onsuggestionsrequested = function (eventObject) {

var text = eventObject.queryText.toLowerCase(); var terms = ["salt", "pepper", "water", "sugar", "oil"];

terms.forEach(function (term) {

if (term.indexOf(text) == 0)

eventObject.request.searchSuggestionCollection.appendQuerySuggestion(term);

});};

Implementing search

Page 23: text uri bitmap html.

Implementing search

Code walk-through

Page 24: text uri bitmap html.

Search tips: If your app implements search, use the charm

Implement a great results page with filter, sort, etc.

Avoid presenting results on the right edge

Provide suggestions

Use placeholder text

Search is not “Find”

Page 25: text uri bitmap html.

Answers to search FAQs

1End-user is in control of the search pane.

Most frequently used searchpane goes to the top

User can turn apps search off in some apps

2You can have separators within results and create headers with these

3Suggestions can be asynchronous

There is a limit of five search suggestions

Page 26: text uri bitmap html.

File Picker contracts

Page 27: text uri bitmap html.

File picker contracts enable seamless integration between apps through the system’s file picking experience

Page 28: text uri bitmap html.

FileOpenPickerCalling app File Picker

Providing app (implements contract)

Calls FileOpenPicker Loads default (last) store

User selects app to provide files

Loads app’s page to display provided files

Activated to provide files

User picks file (or save location)

Navigates to a page that displays files

Completes async calls and captures picked file

Returns picked file to calling app

Page 29: text uri bitmap html.

//Step 1: Declare File Open Picker in manifest

//Step 2: Check app activation and implement file Open

app.onactivated = function activated(args) {

if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.fileOpenPicker) { // Step 3: Connect to the basket

pickerUI = args.detail.fileOpenPickerUI; pickerUI.onfileremoved = fileRemovedFromPickerUI;

//Step 3: Populate basket

args.setPromise(WinJS.UI.processAll() .then(function () { var listView = document.querySelector(".pickerlist").winControl; listView.itemDataSource = getPickerDataSource(); listView.onselectionchanged = updatePickerUI;

})); }}

// Step 4: Add/Remove from basket function updatePickerUI (args){

// .. get filename from listView selected items … Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(fileName).then(function (file) { pickerUI.addFile(file.name, file); }); }

Implementing File Open Picker

Page 30: text uri bitmap html.

Implementing file pickers

Code walk-through

Page 31: text uri bitmap html.

File pickers tipsSupport as many file types as you can

Implement only the right contract, you don’t have to do both

Use deferred when needed

Create dedicated, light, picker UI with app’s context

Set appropriate view mode (e.g., thumbnail or list)

Have commit button on your task

Ensure user gets a visual confirmation

Page 32: text uri bitmap html.

Answers to file picker FAQs

1App selection is matched to supported file types

2Apps are not subject to PLM during picking

3There is no event or notification to the target about a successful file saving operation

4The color from the picker is your app’s color

Page 33: text uri bitmap html.

Contracts cheat-sheet Contract Manifest Activation VS

templateJumpstart

Share source No No N/N Windows.ApplicationModel.DataTransfer.DataTransferManager

Share target Yes Yes Yes Windows.ApplicationModel.DataTransfer.ShareTarget

Search Yes Yes Yes Windows.ApplicationModel.Search

File Open Yes Yes Yes Windows.Storage.Pickers.Provider.FileOpenPickerUI

File Save Yes Yes No Windows.Storage.Pickers.Provider.FileSavePickerUI

Settings No No N/N Windows.UI.ApplicationSettings.SettingsPane

PlayTo Yes No N/N Windows.Media.PlayTo.PlayToManager

Cached file updater

Yes Yes N/N Windows.Storage.Provider.CachedFileUpdaterUI

Page 34: text uri bitmap html.

Recap

Page 35: text uri bitmap html.

More integration points: extensions

Account picture providerBackground tasks Camera settings Contact pickerFile activation Game explorer Print task Protocol activation

Page 38: text uri bitmap html.

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Recommended