What's new in System UI

Hey, everybody, my name is Dan Sandler.

I'm a software engineeron the Android System UI team, and I'm here to tell youabout the new stuff in the system UI in Android 11.

First, how are you doing? We hope you're well.

It's good to see you, although I can't actually see you, but it's nice to imagine.

We're okay, thanks for asking.

The team has been keeping busy.

I avoided giving myself bangs, so you're welcome.

We've got lots of bugsin the Android 11 Beta for you.

Sorry, we've fixed lots of bugsin the Android 11 Beta for you.

But we saved some time for features, and I do want to talkabout a few of them just real briefly for you today.

We're going to talk about conversations, bubbles, device controls, and the media player.

Alright, let's talk about conversations.

We know from our user researchand our own personal experience that notifications to and from real peopleare the most important to us, they bring us the most joy, they are also often the most urgentrequiring prompt response.

Our user research teamhad a really great talk about this a couple of years ago at Google I/O, so I encourage you to go backand check that out– a lot of those conclusionsare definitely still valid today.

What we've done in Android 11 is added a dedicated persistent spacefor these notifications so you can quickly see and respondto them, so let's take a look at that.

First, I'm going to show you Android 10you got here on the left.

It's not bad, but could it be better? We have some conversationsthat are interspersed with lesser urgent notifications.

We have multiple chats from one app compressed into a very small spacein the grouping system.

It's hard to spot any particularsender's name or chatroom name, and those avatars are really smalland kind of off to the side.

Here we have Android 11.

The first thing you're going to noticeis we've got a nice separate section just for conversations with a big section headerto actually explain what that's for.

The next thing you might seeis an unread message indicator.

We had that in Notifications before, but now it's nice and big so that you can see if there's a chatroomthat maybe got a little bit away from you.

It's much easier now, as you look up and down the shade, to see the names of people in chat roomsthat these conversations pertain to.

The primary action, the expand affordanceis much easier to see and get to, and of course, once you expand the notification you can do in-line replies, predicted replies, or launch through into the app.

And then, finally, we made those avatars bigger and moved them all to the same spot, with the same margins.

It looks great.

The user can also long-pressany conversation and mark it as important.

That will make it appear first in the listand break through Do Not Disturb.

That's a featurethat notifications had already.

We made sure it looks really goodand works really well with the conversation space as well.

So, as a developer, what you're asking at this point is, “What do I need to do to get my chat appinto the conversation space?” Alright, get a pen, there's a lot here, are you ready? Step one, use MessagingStyle.

Step two, add a shortcut ID.

Yeah, that's it, just two.




Alright, finally, a code slide.

Let's take a look at how we do this.

First, you want to createthe Person object.

This is something you were already doingif you were using MessagingStyle, since it's required for that API.

And second, you want to create a shortcutand register it with a ShortcutManager.

This might be somethingthat you're already doing if you have Launcher shortcuts or sharing shortcuts, but now you're going to do that for your notifications as well.

There are a couple of new partsthat I want to draw your attention to.

First, the fact that you're marking the shortcut as LongLived, meaning the system can hold on to itand use it in other spaces.

And secondly, attach that Person objectthat you just created.

Then finally, withyour Notification.

Builder, you get to put it all together.

Make sure you include that shortcut ID, and everythingis going to work just great.

Alright, let's talk about bubbles.

You may remember bubbles from Android 10 when we showed it offas a developer preview feature.

Well, it has graduatedfrom a developer preview to a full user feature as partof our conversation system.

The user can grab a conversationthat they're actively engaging with, pull it out into a bubble that floats on top of the phone display, as a part of a multitasking feature.

To do this, you're going to usethe BubbleMetadata, which we introduced, again, last year in Android 10.

But the new thing here is that you're going to addthat same shortcut ID that you put togetherfor the conversation space.

The bubble is automatically going to pullthe icon out of that shortcut ID.

Make sure it's an adaptive icon as well so that it fills the whole shapeof the bubble.

And then make sure, as before, when you put the PendingIntentinto the BubbleMetadata, that that PendingIntent points to an activity that is resizable, because this is a multi-window feature, and that window is going to show up at a different size than the display, so it needs to be preparedto be resizable.

In the coming weeks, we're going to have a talk entirely dedicated to all things, conversations, bubbles, and notifications in Android 11, so look for that coming soon.

Okay, let's talk about device controls.

This is really fun.

In Android 11, we've created a new dedicated persistent space for your homeand Internet of Things controls so that you can quickly findand use them at any time.

We've redesignedthe power menu for this.

It places your device controls just a button-press awayor a long button-press away.

As a user, you can choosethe set of controls you use most.

Those will show up here in the Power menu, and you can actually switch betweendifferent providers from different apps that provide IoT and home controls.

To do this, we've introduceda brand new API the android.


controls API suitefor device control providers.

It's one of our firstJava 9 Reactive Streams APIs, so grab your favorite flow implementation, and let's get started.

Your implementationof the ControlsProviderService has a few key APIsthat it will need to implement.

The first one is to createPublisherForAllAvailable controls, so Publisher in Reactive Streams means that's a thingthat's going to be able to generate new instances of the objectas they change.

In this case, the Publisher is goingto list all of the controls objects that you know about as a provider that the user might want to choose from.

There's a similar APIthat you'll also need to implement that is just createPublisherFor.

This is what the system UI is going to use when it knows which are the controlsthe user really wants to engage with and just wants to ask you for updatesabout those three, or four, or five or twenty.

And finally, your ControlsProviderService wants to know when the userhas clicked on a control, and that's what performControlAction is for.

You're going to knowwhat control was clicked on, what kind of action it was, if it was a click or a drag, something like that.

And then you're going to geta Consumer object to which you can passa status of Response.

ok, letting it know that you heardthe response and have actually made the changein the real world that the user has asked for.

Okay, here's an exampleof one of those Control objects that your publishers are going to push.

It's a simple objectrepresenting a light bulb.

There are a few pieces.

There is a pendingIntent, first of all, which is a way for the user to long-press on the controland get back into your app to be able to control all the things inside your app's context.

There's also a Template, that tells the system UIhow to actually draw that control.

And then, finally, wrap it all uptogether in a Control Builder that hold some state, that you then put intothe publisher and send a system UI.

This is a more complicated example.

It's a description of a thermostat.

There's actuallyquite a lot going on there.

I'm not going to read through all the code here.

But this and a lot of other device typesare supported by the system.

Go ahead and check the API documentation with the 11 Beta.

Okay, finally let's talk about the media player.

This is mostly an end-user feature, but there's a few APIsin here too to be aware of.

First of all, in Android Lollipop, we introduced the MediaStyle notification so that apps didn't have to keepusing remote views for their media playback.

And most of you are usingMediaStyle by now.



most of you.

Android 11 createsa dedicated persistence space for all of these media players so that the user can quickly controland even resume content.

Are you seeing a pattern here? Yes, we have a lot of dedicatedpersistent spaces in Android 11 for the stuff that we know users use a lotand need to be able to get access to.

So media controls now live in the Quick Settings panel for easy access, no matter what app is in frontor which notifications you've received.

And yes, they even show upon the lock screen.

And we've even added an output pickerright there in the media player.



you're welcome! So I did say there wasa little bit of API.

If you, as a media player app, implement MediaBrowserService, your card can actually be resumed.

That means the system UI will hang on to it and let the user go backand pick up that podcast or that two-hour-long synthwave set hours after they have paused itor possibly even after a reboot, even after that media sessionis destroyed.

Okay, that's all I've got.

Go get the Android 11 Beta, try out those APIs, report those bugs, we really need those reports, and thank you for watching.

This was fun.



for me.

Hopefully, for you too.

Still miss Chet and Romain.


Hãy bình luận đầu tiên

Để lại một phản hồi

Thư điện tử của bạn sẽ không được hiện thị công khai.