470 likes | 701 Views
PLAT-894T. Seamlessly interacting with web and l ocal data. Manav Mishra Principal Group Program Manager Microsoft Corporation. Windows 8 allows seamless access to files wherever it lives – local , devices , network, web or contained within other apps. Files.
E N D
PLAT-894T Seamlessly interacting with web and local data Manav Mishra Principal Group Program Manager Microsoft Corporation
Windows 8 allows seamless access to files wherever it lives – local, devices, network, web or contained within other apps
Files • We use and create files everyday • Files live in various places • Each place has unique restrictions and access models
Agenda • File access in Windows 8 • Compelling views of local files in your app, easily • Seamless interchange of web and local file representations • App-to-app file exchange with contracts You’ll leave with examples of how to Get started with file access in Windows 8
Files in Windows 8 Web (via manifest) 1 Drives & network (via Picker) Local files (via manifest) App data (free)
Windows 8 file access building blocks Metro style Apps ListView Control Windows 8 file access File data source File access API File picker App-to-app contracts 2 4 1 Trust broker 3 Type interchange Windows Core OS Services File system File system indexer
1. Accessing the file system “It’s the PC reimagined”
File access • Declarative access to the most-used system places– music, videos, pictures and documents libraries, using the manifest • Enables programmatic access • File picker gets full-fidelity file system access for free, with user-consent • Enables programmatic access
File actions • Full enumeration of files and folders • Rich search and metadata pivots of user files • Access to thumbnails and properties of files • Core file actions like new, copy, delete, rename and move
demo File system access
Brokered file access • Declare access to the music library in the app manifest • <Capabilities> • <Capability Name= "musicLibrary" /> • </Capabilities>
Brokered file access Get all the music in the music library var picturesLibrary = Windows.Storage.KnownFolders.musicLibrary; musicLibrary.getFilesAsync().then(function (file) { …
Brokered file access Delete a file sampleFile.deleteAsync().then(function (file) { …
File pickerFull-fidelity file system access for free • System control optimized for rich browsing of file locations • Enables opening & saving files for all local and network locations • Offers photos and attachment views • Apps choose file types they want the picker to filter-by • Supports ‘basket’ for multiple selection scenarios
demo File picker
File picker • Show the file picker with filters • var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); • openPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]); • openPicker.pickSingleFileAsync().then(function (file) { …
File picker Show the file picker in multiselect mode openPicker.pickMultipleFilesAsync().then(function (file) { …
File picker Show the file picker in thumbnail mode openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
File broker and picker offer apps full access to the file system while keeping the user in control
2. Building compelling views of local files, easily “Data-source adapter”
Building compelling views ListView data-source adapter • Communicates between the file system and the ListView control • Uses system indexer to populate metadata in the view • Automatic support for virtualized views for fast scrolling • Automatically loads thumbnails in reading order • Automatically handles change notifications
demo ListView data-source SDK sample
ListView data-source adapter • Define library to access • var pics = Windows.Storage.KnownFolders.picturesLibrary; • Configure data-source • var dsOptions = { • mode: Windows.Storage.FileProperties.ThumbnailMode.picturesView, • requestedThumbnailSize: 192, • synchronous: false • };
ListView data-source adapter • Configure ListView • var lvOptions = { • dataSource: new WinJS.UI.StorageDataSource(pics, dsOptions), • layout: new WinJS.UI.GridLayout(), • };
ListView data-source adapter Create ListView new WinJS.UI.ListView(document.getElementById("listviewDiv"), lvOptions);
3. Type interchange makes interchange of file representations, seamless
Interchanging web and local file representations • Bring forward existing knowledge, expertise and scenarios for interacting with any content abstraction, be it web or local • Seamless interchange between local and web representations
Data typesInterchange http:// Playback a video… …that was transcoded on the fly … …after being uploaded to a service… …from a file which was picked from the file picker URL URI Stream Blob File Stream Blob File
demo File type interchange
Seamless interchange between web and local file representation, for your scenarios
4. App-to-app file exchange with contracts Experience gets better with more apps
App-to-app contractsBetter with more apps • Users think about their content in an app-centric way“My pictures are on my photo sharing service” • File picker contract enables • Seamlessly integration with the system file picking experience • Delight users with a rich view that only your app can produce
demo File picker contract
File Picker contractBetter with more apps Web files Socialite File picker contract Tweet@rama App data User files
File picker contract • Register in Manifest • <Extensions> • <Extension Category="windows.filePicker“ • StartPage="filePicker.html">
File picker contract • Connecting to the File Picker basket • function onActivated(e) { • if (e.kind === Windows.ApplicationModel.ActivationKind.FilePicker) { • var basket = e.basket; • basket.addEventListener("fileRemoved", onFileRemoved); • } • }
File picker contract • Add & remove files from the File Picker basket • function onItemIndicated(myItem) { • if (basket.containsFile(myItem.id)) { • basket.removeFile(myItem.id); • } else { • basket.addFile(myItem.id, myItem.storageFile); • } • }
App-app contracts make the experience better as more apps are installed
Recap • File broker and picker offer apps full access to the file system while keeping the user in control • Building compelling gallery views of local files very easy, with the data-source adapter • Seamless interchange between web and local file representations, for your scenarios • App-app contracts make the experience better as more apps are installed
Related sessions • [PLAT-891T] Using files: accessing, searching and acting on files • [PLAT-892T] Building great Metro style gallery apps today • [APP-398T] How to declare your app’s capabilities • [APP-405T] Share: your app powers the Windows 8 share experience • [PLAT-282T] File type associations and AutoPlay
Further reading and documentation • Accessing files and data • Adding file picker controls • Accessing files and data • Windows application contracts • Contact info – • Manav Mishra • http://forums.dev.windows.com (mention PLAT-894T) • Find me at the booth right after the talk
thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback
© 2011 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.