What’s New in Android Support Library (Google I/O ’17)
Articles Blog

What’s New in Android Support Library (Google I/O ’17)

August 10, 2019

morning, everyone. Welcome to What’s New
in Support Library. I’m Alan Viverett. I’m tech lead for the
Android Support Library team. CLARA BAYARRI:
I’m Clara Bayarri. I’m a tech lead on the
Android UI Toolkit team. ALAN VIVERETT: And we’re going
to be talking about what’s new in Support Library from
25.3 through today’s release, 26.0 Beta 1. So has anybody here
not used the Support Library to develop
an Android app? One person. Do you actually
develop Android apps? OK, so everybody here is pretty
familiar with the Support Library. It’s a collection of
utilities and classes that make it easy to target
older versions of the platform, use some new concepts like
material design widgets, and it’s a very essential part
of Android app development. So we’re going to start
by talking about what’s old in the Android
Support Library before we move on to what’s new. So last year you may recall
that we dropped support for SDKs lower than 9. So Donut, Eclair,
and Froyo went away. And this allowed us to
focus more on the API levels that developers are
actually targeting. So a lot of compat
code went away and we reduced our method
count by quite a bit. And when you’re targeting
platforms earlier than 21, you’re worried about
the 65k dex limit. This is really helpful. So today, we have fewer than
1% of active Android devices, according to Play
Store check-ins, on APIs lower than 14. So you may guess what
I’m about to say. Is anybody still
targeting Gingerbread? One or two people. You probably have a
sinking feeling right now. So as you might have guessed,
we are removing support for APIs lower than 14. [APPLAUSE] And the Support Library team is
as happy about that as you are. So we’ve got some great
benefits from this, but the main thing is that if
you’re a minSDK is not already 14, it will become 14. If you’re still targeting older
versions, the three of you in this room that are still
targeting Gingerbread, you can still use the existing
versions of Support Library. So 25.3 is going
to continue to work on Gingerbread and Honeycomb. But if you want to use
some of the new features that we’re talking
about today, you’ll need to maybe have a
separate code branch where your minSDK is 14. All right, so some of
the benefits that you’re going to get from this. We’ve dropped over
1,400 methods. So we’re a little bit backing
off from the DEX limit. And we’re going to be removing
even more classes and methods. So just public methods and
classes and interfaces. We’re deprecating 30 classes,
over 400 methods that are no longer
necessary, because there are compat wrappers
for APIs that actually exist on 14 and above. So for example,
ViewCompat.setPivotX is now going to show up as deprecated. And you can replace
that with a call to the actual setPivotX
method, because that exists. There are some methods
where we have workarounds for bugs in existing versions. So it may still be useful
to be calling ViewCompat, but anywhere that’s
been deprecated, you can go ahead and
migrate away from. And we’ll be removing those
methods in a later version. All right, so we’ve
made it easier to develop with the
Android Support Library. We’re also going to be
improving the way that you get the Android Support Library. We’ve modernized our
distribution method and added the Google
Maven Repository. [CHEERING] So every time we update the
Support Library with a bug fix, you don’t have to download 500
megabytes of internal Maven Repository. So we’re including
Support Library as well as constraint layout, the
application architecture components that you may
have heard about yesterday, through this Maven Repository. We’re including every historical
version of Support Library, including 26 Beta
1, which is only available through the
Google Maven Repo. So you can go ahead and
make this transition, even if you’re not targeting 26 yet. And it’s as simple as just
adding the Google Maven Repository to your
Maven repositories in your build.gradle,
and then everything else continues as usual. So you just set up your
compile dependencies and you’re good to go. And just a moment while a
bunch of people take photos. The slides will be
available later, so any links that we’re
showing you can look at later. So we’ve made it easier to
obtain the Support Library. We’ve made it easier to develop
with the Support Library. We also want to make it
easier to develop the Support Library itself. So we’re improving workflow
with our Issue Tracker. We’ve moved from
Google code to our new issuetracker.google.com. And this is providing a
much, much better tool for us to track bugs, manage hot
lists, and respond to you and let you know that
we’re following up on what you’re telling us about bugs. But this is also better for you. It’s more stable. And this is going to
provide a faster response time when you file bugs. But– thank you. So when you file
a bug, sometimes maybe we’re slow to respond. We try hard, but there
are a lot of bugs. So if you decide that you
want to handle a bug yourself, we have support for developing
Support Library from AOSP in Android Studio. So if you check out our
minimal branch of AOSP, an unbundled Support
Library branch that is I think around
6 gigs right now, instead of the full 150
gig Android checkout, you can open the framework
support root in Android Studio. Everything works. You don’t have a bunch
of weird red error lines. If you’ve tried to develop
AOSP code, framework code, in IntelliJ, you’ve
probably had a rough time. But we have vastly
streamlined the experience for developing Support Library. And we want to get
patches from you. So we have a guideline for
external contributions now available on
android.googlesource.com in the framework
support section. So if you send us
a pull request, you send us a [INAUDIBLE]
CL review for bug fixes only right now. We’re not taking API changes. For bug fixes,
we’ll look at those. We’ll give you feedback. And hopefully, we’ll be
able to integrate those into our main repository. And now over to Clara
to talk about some of the actual new features. CLARA BAYARRI: Thank you, Alan. It’s an exciting year for techs. We have four main features
that we’re presenting today. They’re in Android O and
they’re all in the Support Library 26 Beta 1. Let me start. The first feature I
want to present today, we’re calling it Fonts in XML. If you’ve ever tried to use
a custom font in your app, you might be familiar to
a painful process that looks something like this. You create your custom TextView,
you load your typeface– well, you get it from
the typeface APIs, you load it onto yourself. And then the worst part,
you use your custom typeface everywhere in your XMLs. That’s not fun. We’ve seen some more
clever ideas out there, like people using data
[INAUDIBLE] to solve this, but we decided to fix
this in the framework. So starting now, fonts
are a new resource type. We have created– thank you. [APPLAUSE] You can now put all
of your font files into the res/font font folder. We will be taking care
of creating IDs for you. We are also adding
support for font families. Font families are when
you have more than one file to define a font. So for example, you have a
regular, a bolt, an italic, and a bold italic file, and you
want to treat those as a unit. We are adding support
for that as well. So we’ve defined
new XML attributes. You can define an XML
with a font family tag and font tags for each of
your fonts in the family. You can see here,
I’ve defined a family with a regular and a bold font. Creating this, you tell us
what the style and the weight is for each of the files,
and then this, for example, would generate r.font.myfont. This is a family. It can be used as a
unit and everywhere. The framework will take care
of selecting the font it wants from that group. So you may be familiar with the
Android font family attribute in TextView. This has existed
since way before. It takes strings, so it takes
things like san serif, cursive, or monospace. Well, we’ve extended it
now to take font resources. So you can now say
android:fontFamily @font/myfont, and it just works. We’ve also added support,
obviously, for text styles. So text style
already interested. If font/myfont
here were a family and you tell us to use
bold, we will automatically use the bold front
within your family. This also applies to text
spans, so if you’re using spans within your text to
define different styles, we will automatically
select the font for you and take care of everything. As you can imagine, it
also works with styles. Just define it yourself,
set it on your TextView, everything works. And if you want your
resource from code, we’ve added
ResourcesCompat.getFont. Just give us the ID, we’ll
give you a typeface back. This is all available
to you today on APIs 14 and above thanks to
the Support Library. [APPLAUSE] So let me move on to
another fonts feature. We have downloadable fonts. We noticed that lots of you
bundle fonts into your APK. And fonts are really
large files, even more, like, you are probably
bundling fonts that are not even optimized for mobile. And it turns out that Android
doesn’t need about 50% of the file. We don’t need it for
mobile, but you are still bundling it into your app. We made a little
analysis and we’ve found that the top 25 apps
on the Play Store that do bundle fonts are bundling an
average of about 500k in fonts that we have in the
Google Fonts catalog. Couldn’t we do better with that? Also, never to mention the fact
that you are bundling the same font in several different apps. And the user is downloading
this font over and over again. So this is where downloadable
fonts comes into place. We’ve created the concept
of a font provider. And a font provider
is the separate entity that is not your app,
and its own mission is to fetch fonts, cache
them, and serve them to you and to every other
app that wants fonts. So then, hopefully, you can
get rid of your bundled fonts and just rely on a font
provider to give you all of the fonts you want. The way this works
is all apps can access a font provider via
the FontsContractCompat APIs. This means that you all
have one entry point into the font provider. The benefits of this are– oh
sorry, can you go back one? The benefits of this if we
have one copy of the font. We only have one copy
of the font on memory, saving memory for the user. We have one copy
on the device, one copy so that you don’t have
to bundle it in your APK. And we’re only
downloading it once from the network if you are
also downloading it yourself. We’re very proud to
announce that our very first font provider
available today to you is a collaboration with
the Google Fonts team. We are providing the
entire Google Fonts catalog through Google Play Services
so that your app can use all of the Google fonts. That is more than 800 fonts
just out there for you. [APPLAUSE] The way this works
in code is you need to create a
FontRequest that just tells us what font you want. So you will give us an authority
and a package for the provider, the actual query of the font– so say you want
Comic Sans, maybe– and then the array
of certificates that the provider
is signed with. This is very important. Fonts are kind of a
security loophole. They can load code and
they can execute code. So we want to make sure you
have a trust relationship with your font provider. You don’t want to be
loading fonts from anywhere. For example, we can assure
you that all the Google fonts available in Google
Play Services, we have verified them. We know they are secure and we
know they are mobile optimized. Next, you will
create a callback. And the callback has
two main functions, one for when the typeface
is successfully retrieved and one for when
there’s a failure and what the failure was. Once you have these
two components, you will call
FontsContractCompat.requestFont, and that just takes a context,
the request and the callback that you just generated,
and a handler. Requesting fonts
may take some time. We are making a connection
into a font provider, so we want to make sure
that you have control over where this is executed. Please do not give us
a UI thread handler. We may block your UI thread. So it’s all under your control. Because I just talked
of fonts in XML, isn’t it obvious that we
tied these two together? You can obviously specify
your downloaded fonts in XML. We’ve added four attributes
to the font family tag for the authority, package,
query, and certificates. This is equivalent to
creating a font request. You just specify it in XML,
use it in all of your layouts, and we will take care
of fetching the font and displaying it for you. Obviously, if the
font takes too long, we may time out and render
in the default system fonts, so bear that in mind. Next, I want to show you the
Android Studio team have done a great collaboration with us. As you can see, I
have a TextView here. If you open the Properties
in Android Studio, you’ll see there’s a
Font Family section. Usually it takes things like
san serif, cursive, monospace. Now if you open it– there you go– and you scroll
all the way to the bottom, there is a More Fonts option. That opens the new Font Picker. Font Picker will show you
fonts that are already in your project because
you bundle them, fonts that are in the Android
system, and downloadable fonts. Right now, you may
notice on the top right, the source says Google Fonts. We are ready to integrate
with any other font provider that comes out. Right now, it shows
all of Google Fonts, so if you scroll up it, you will
see that is the entire catalog. Right now, I want
to search for fonts. so for example, Pacifica is
one of my favorite fonts. So I’ll search for it,
select it, just hit OK. Android Studio generates
all of the XML for me and even pre-renders it to
show me what it will look like. [APPLAUSE] Notice that if we open
the XML that it generated, it generated the four
attributes we needed and all of the certificates
needed for Google Play Services, all for free. If you want to know more
about the Android Studio, go check out What’s New in
Android Development Tools. It’s today at 11:30
in the amphitheater. For more information
on downloadable fonts, we do have a sample
app that is published on GitHub since yesterday. We have public documentation
that you can access. Again, the slides will
be available later, so don’t worry about the links. We have Google
Fonts documentation that will tell you how to
use the Google Fonts Font Provider specifically. And the one caveat to
use the Google Fonts, because we’ve done
an integration in Google Play Services v11,
that is not out to the public just yet. But you can join their beta
through that link over there and get v11 so that you can play
around with it as a developer until it actually rolls out. Downloadable fonts available
to everyone API 14 and above. [APPLAUSE] Thanks. Next, let’s talk about emoji. Have you ever seen one of
these boxes with a cross in the middle? We call this tofu,
and it’s what we render when we can’t render
a glyph you’ve asked for. This is extremely
common in emoji. Every year, the Unicode
defines more emojis. And it turns out that our emoji
font is bundled in your system, so we can’t actually update it. We can’t actually give you
all of these new emojis. So you start seeing these. Maybe you, with a new
device, will send an emoji to your friend who
has a Kit Kat device. They will never
actually see that emoji. And that’s really bad. So we’ve decided to fix this. The Emoji Compatibility
Library is a support library that has access to
newer emoji fonts. So what we do is for each emoji
that you’re trying to render, we check if the system
font can render it. If so, we just leave it be. If it can’t, we
substitute it with what we call an emoji span. And that means that we can
use our available emoji font to actually
render that for you. There are two ways to use the
Emoji Compatibility Library. You can either bundle
the font into your app or you can let us use
downloadable fonts to actually get the latest
emoji font for you from Google Play Services
and Google Fonts. So to look at
this, when you want to use a downloaded
configuration, you will use a support
emoji dependency. You will then create a
fontRequest, which we’ve just seen in downloadable fonts. You will be able to get
these values from Google Play Services and Google Fonts to
actually use their emoji font. And then you
initialize EmojiCompat with a
FontRequestEmojiCompatConfig. Request And this just tells it
to go find the downloaded font. If you do this in your
application on Create, then you’re set. If you say, oh, but I actually
target non-Google Play Services devices, I can’t use this. That’s fine. We have the bundled
configuration for you. You use a different dependency. You use support-emoji-bundled
dependency. And what that does is it
pulls the latest font we have at that moment into your APK. Do note, that font
is about 7 megabytes, so be careful with this. And of course, once
you’ve shipped your app, it will not get updated,
so it’s up to you to ship a new update on your
app to get the newer fonts. To do this–
extremely easy– you create a
BundledEmojiCompatConfig, set it, initialize on
EmojiCompat, and you’re set. Then to actually use
the emojis in your app, we’ve provided some
widgets for you. So we have EmojiTextView,
EmojiEditText, and EmojiButton. These automatically
use EmojiCompat, render all of the emojis for you. Some of you might say, oh,
but I have my custom class. I don’t want to use this
one or extend this one. I have my own thing. Go read the documentation. We have very
detailed steps on how to integrate EmojiCompat into
your own custom class as well. Hopefully, you will
stop seeing tofu, especially if you’re something
like a messaging app. This is really important to you. You will start showing
images to your users. Again, some links. We have a sample app. It’s available on GitHub. We have public documentation
on how to use this. And because– if you use a
downloaded configuration, you are using
downloadable fonts. It has the same caveat. We need Google Play
Services v11 beta, so please sign up to the beta
to play around with that. This is available to
everyone APIs 19 and above. Finally, I want to present our
fourth and important feature. We’ve made TextView autosizing. What this means
is you might have run into this case where
you have some text. You’ve carefully
measured your TextView. You know your text fits. And then your translations
come around and they’re longer and they don’t fit. And you start seeing
that your text doesn’t fit into its bounds. Well, that’s where
autosizing can help you. What we do with autosizing is
we choose the size of the text depending on the
boundaries of the TextView. So as you can see, we will
increase your text size as needed to fill
in its container. Using this is really,
really simple. You use this autosize text
type attribute on TextView and set it to Uniform. What this will do is
it will scale the text both in x and y-axis uniformly. Some of you may say, oh,
but I need more control. I can’t just let my
text be any size. My UX people would kill me. That’s fine. We have more control for you. You may give us either an array
of preset sizes, in which case, we will take the best
match out of the sizes you give us for the
given boundaries. Or you can give us a
minimum, a maximum size, and a step or granularity. What we do with this is,
for example, in this case, you say from 12 to
100 in steps of 2. We will take values such as
12, 14, 16, 18, and so on, and we will snap
only to those sizes. Autosizing TextView is
available to you today in Support Library
for APIs 14 and above. Now let me hand it back to
Alan to talk about innovations. ALAN VIVERETT: All
right, so now that we’ve made our apps beautiful
by switching everything over to Comic Sans
and adding new emoji, let’s also make our
animations beautiful. So Support Library
26 adds a number of backwards
compatible improvements to graphics and animations. And first among these
is dynamic animation. So this is going to be a
library for direct interaction and animations in
response to that. So these are based on
velocity instead of duration. You may have had
an animation where a user touches the screen,
drags something down, and the touch has some
sense of velocity. So you want to fling
something off the screen and you want the velocity
to match their initial touch movement. And you can run
those calculations, and you can figure out an
interpolation curve that’s going to roughly
match what they were doing before the
animation started, but it can be a lot of work. So dynamic animation
is going to help you create natural-looking
animations in response to direct user interaction. We’ve provided two animations
right now– spring animation and fling animation. And these are
respectively for behavior where you want to
drag something down, and maybe it snaps back
and eventually reaches an equilibrium point, or
maybe you grab something and you fling it off
the screen and you want it to slow down as
though there’s friction. So what that looks
like in practice is I have an Android view, a
Bugdroid view, and I touch it. And as I’m pulling it down,
we start feeding touch events into a velocity tracker. So this knows how
fast the Bugdroid is going to be moving
when I let go of it. As I’m moving it down, we’re
tracking the y-translation so that it follows my finger. And when I remove
my finger, we’re going to start our dynamic
animation, our spring animation, on our Bugdroid view. So from code that
looks like this, we’re creating a new spring
animation on our Bugdroid view. We’re going to be
animating the translation y, the vertical translation
that we’ve been using to track our user interaction. And when I let go
of that, I want it to return to an equilibrium
state of zero translation y. So when it springs up,
it’s going to overshoot. It’s going to overshoot. And eventually, it’s going to
settle on zero translation in y as equilibrium. Spring animation uses physical
properties of springs. So the damping ratio is
how quickly the spring is going to come to rest. A damping ratio of zero
would oscillate infinitely. A very high damping ratio will
stop animating very quickly. Stiffness is how quickly the
spring is going to snap back. So a very high stiffness,
when I pull the spring down, it’s going to snap
back immediately. A very low stiffness
would be like a car with a loose suspension. It’s going to just bounce
back and forth slowly. Finally, I want to
pull in the velocity that I’ve been tracking. This is the direct
interaction portion. So I pull it down very quickly. When I lift my finger
up, I want it to keep moving with that energy. If I move my finger very slowly,
I’m going to lift my finger up and I want it to
start moving back, because there’s very little
energy that my finger is putting into it. Then finally, we
start our animation and we end up with
an Android that snaps back, springs
a little bit, and eventually comes
to rest at equilibrium. If you want to learn more
about dynamic animations, you can check out Android
Animations Spring to Life. That’ll be tomorrow at
2:30, stage 2 right here. We’ve also made
some improvements to drawing with
vector drawables. We’ve added feature
parity with fill type. So fill type, if you’ve ever
received an asset from UX that has hollow areas in
the middle, so here we have a light bulb that
has a single path defining the entire area and it
has some empty areas. So this looks great in Photoshop
when our designer exports it. This looks great
in Asset Studio, which is rendering as though
you’re on the latest platform. But once you load it onto
a device running API lower than 24, you see that there’s
some weird artifacting at the edges. And the reasoning for that
is the format of SVG that gets exported by our tool,
in this case Photoshop, uses a fill rule. And this defines what the
inside of our vector path is. So you’ll notice we
have a single path that defines our light bulb. We have a rule that tells the
renderer which is inside fill and which is outside fill,
which is transparent. So this was added in
the framework in API 24, and we’ve now
backported it to API 14. So the assets that
you’re using, generating from Android Studio, the
assets that your designers are generating from
Photoshop, you can just use across all supported APIs. [APPLAUSE] So you write one
XML and it looks correct across all platforms. Nobody has to go and hand
edit things so that you can use a single fill rule. All right, speaking
of vectors and parity, we’re adding parity
for the ability to morph between different
paths and interpolate along a path for AnimatedVector
DrawableCompat. So again, these are
some new features on the platform that were
backporting to API 14. You’ll be using the
same XML on API 24, API 26 that you would on API 14. And here for path
data morphing, we’re going to be able to
take an initial path spec, so the long string of
numbers and letters and commas that you may see if you actually
dive down into your vector drawable paths. One caveat here is the
path formats must match. And this is something that
can be handled by tools. We use Alex Lockwood’s
ShapeShifter tool for this demo that we’re about to show. So here’s what path morphing
looks like on a device. A very common case of morphing
from a buffalo to a hippo to an elephant that
I’m sure you’re all familiar with in
your Android apps. All right, so let’s
look at what’s going on at the XML level. We have a vector
drawable defining our starting image, a buffalo. And here I’ve extracted out
our path data for the buffalo. So that long string
of letters and numbers that defines our
vector path I’ve pulled out into a
string resource. And we’re going to be
reusing it in our animation. And this also just makes
things way more readable. So we have our
starting vector XML that we want to animate from. And we have our object animator. Now, the new thing here
for API 14 and above is the ability to specify path
data as your property type. So we’re going to animate the
value from our buffalo path spec to our hippo path spec. And this is actually going
to transform the points and give us that morphing
animation that we saw. We pull this all together
into an animated vector which points the drawable
to our starting buffalo. The target, we’re taking our
buffalo path from that drawable and we’re going to
be morphing the path data from a buffalo to a hippo. So we’re going to take this
a little bit further and take advantage of a feature in AAPT
to use a bundled XML format. So you may not have used this
before, but it’s really cool. This is supported through AAPT,
so it’s backwards compatible. We’re going to
take this and we’re going to take our drawable
and expand that out into an attr element. This replaces the Android
drawable attribute in our animated vector element. And we’re going to inline
our initial drawable, our buffalo vector drawable
XML in this element. So now we’ve gotten
rid of our buffalo.xml and we’ve centralized things
in our animal_morph_bundle.xml. So if you’re not
reusing buffalo.xml, you just need it
for this animation, it can really simplify and clean
up your resources directory. We’re going do the same
thing with our animation. And now we have everything
neatly contained in one file. So the only thing
that we’re going to reference from our layout
XML or reference from code is our animal_morph_bundle
drawable. And we don’t need to
keep a separate animation XML in some other
resources folder somewhere. If we’re trying to send
assets between developers or from designers to
developers and vice versa, we don’t have to bundle
everything into a zip and then tell everyone, OK,
this goes in the anim directory, this goes in– everything is one file. Very clean, supported all
the way down to API 14 through AAPT. We’ve also backported support
for interpolation along a path. So this provides parity
with the platform AVD again. And this is going
to allow you to set the interpolator on
your object animators to be a path using a spec
similar to what you would use for SVG and what we support
in vector drawable path data. So here’s an example of
combined path morphing and path interpolation. This one’s pretty
complicated, so we’re going to take a slightly more
simple example to break down how it came together. Let’s say our UX
designer was not feeling particularly
creative and they want us to shrink down a square. But they want it to have
an interesting acceleration curve as it’s shrinking down. So we’re going to
shrink down real fast, bounce back a little bit,
and then slowly reduce it to a point. So our path interpolator
that we use on API 14 through current API 26 is
going to look like this. We define our path data
as an SVG-like path, a vector drawable path data. And if you render that,
it looks like this. So our curve is quickly
reducing from 1.0, we’re bouncing
back a little bit, and then we’re slowly
tapering off to zero. And this is what you see
when it shrinks very quickly and then gets a
little bit larger and shrinks down to zero. It’s very easy to use this
in our object animator. Again, compatible, same
XML for API 14 and 26. We just set our interpolator to
be our new path interpolator. Once again, I’m going
to pull everything out into an XML bundle because
it helps clean things up. And then we get this
quick shrink and then a slow fade to zero. All right, so far, all
the screenshots and videos that I’ve shown you
are from phones. But Support Library 26
also introduces a number of changes for alternative form
factors, like watches and TVs. So on the watch side
of things, we’re integrating the Android
Wearable Support Library into the mainline
Android Support Library. So what you’re going to see
is a number of improvements in core UI elements. Things like improved
circular scrolling with WearableRecyclerView,
better support for responsive layouts
on round screens and square screens
with Box Inset Layout, and consistent user interaction
models from classes like Swipe Dismiss Frame Layout. So you can learn more about
developing for Wear devices at the Android Wear
UI Best Practices talk, which will be at this
stage on Friday at 3:30 PM, tomorrow. We’ve also made some
improvements for developing TV interfaces. So the Leanback
Library has added PlaybackTransportControlGlue,
which adds a seek interface for videos. And if you’re writing an
interface for Leanback, this is probably something that
was painful to do yourself. So we have a prepackaged
seek with preview. And we’re also allowing
you to embed a video view inside of a detail fragment. So if you’re writing
something for browsing media and you want to be able to play
that media inline while you’re showing people the description
of it or the ratings of it, that’s now very simple to
do with DetailsFragmentB ackgroundController. And if you want to learn more
about developing for TVs, you already missed the What’s
New for Android TV talk. However, you can check
out their office hours at 6:30 this evening
in Section 3. So we have a number of other
smaller behavior changes and new classes that I think
it’s important for everyone to know about in the 26 release
of Android Support Library. So first of all,
PreferenceDataStore. For anyone who’s storing their
preferences in the cloud, you may have had to do
something a little tricky if you’re using the
normal Preference fragment and PreferenceManager. So this allows you to customize
the way that you’re PUT and GET calls for
preferences are handled. So the implementation
of this, let’s say we want to store
preferences in the cloud. We’ll extend
PreferenceDataStore, the new class, and
we’ll override, here, just getBoolean and putBoolean. So when we put a
Boolean preference in, we’re going to start some
asynchronous call that stores it in the cloud. Now, because we want
to be able to retrieve a value without having to
wait for cloud interaction, we’re going to store
this locally as well. And an important thing to
keep in mind with this class is that calls are going to
happen on the main thread. So if you’re doing
some long transaction, you’re doing something
in the cloud, you’re persisting
something to disk, you want to do it
asynchronously and have some way to handle quick calls
after that to get Booleans. So something like local caching. To set this up on our
Preference fragment, we’re just going to grab
our PreferenceManager. We’re going to set an instance
of our PreferenceDataStore on that. And all subsequent GET and
PUT calls to our preferences are going to go through our
new PreferenceDataStore. We also have some changes
in FragmentManager that are important
to know about. So transaction calls, things
like executePendingTransaction commitNow can be
dangerous to call if you’re already
in a transaction, if you’re already
in a state change. These can be re-entrant and
have some unexpected behavior. So we want to make it
a little bit easier to do the right thing,
more difficult to do the wrong thing. And these will now
be strictly enforced and throw exceptions
if you’re trying to do re-entrant transaction calls. And for developers
interested in learning about their UI
performance, we’ve added FrameMetricsAggregator. So this allows you to
attach to an activity and get information about
rendering milestones during the lifecycle
of a drawing frame. Now, if you don’t know what a
rendering milestone is, or you do know and you
want to learn more about assessing the
performance of your UI, you can check out the
Android Performance UI talk. If you don’t care about
performance of your UI talk, but you saw Chet’s talk
yesterday, Speechless, and you just really love
Chet talks, it has Chet. So you can check that out
Friday at 1:30 PM on Stage 4. And last but not least, this
is actually from 25.3 API, but I thought it was
really important. So ActionBarDrawerToggle
is this class used to implement the Hamburger
button, the button that you use to open the Navigation
Drawer, the three lines. And you may have
noticed in some apps that when you start to pull your
drawer out over the Hamburger button, it animates. And this is officially
not the thing that you’re supposed
to do, but I see a lot of apps that have done it. I see a lot of
apps where it looks like you’ve probably fixed it. So that it looks like
this when it’s wrong. We pull it and the Hamburger
turns just a little bit. Some lettuce is falling out. So you noticed it
wasn’t quite right. Maybe you fixed it. Maybe the way that you fixed
it took a couple hundred lines because it was
really difficult to do. Don’t do that. Stop that and instead do this. We now have one line to disable
the drawer slide animation and get the correct behavior. So use that. And also, check out some of
the next talks that we have, some of the talks that
we’ve referenced today. So we have What’s New in
Android Developer Tools if you want to learn
more about things like the font tool that’s
integrated into Android Studio. Android Performance UI, if
you want to see Chet on stage again. Android Animation Spring to
Life for direct interaction. And Android Wear
UI Best Practices for learning how to create
UIs optimized for watches. So thanks everybody. CLARA BAYARRI: Thank you. ALAN VIVERETT: We’ll be around
for questions afterwards. [APPLAUSE] [MUSIC PLAYING]

Only registered users can comment.

  1. 11:35
    Although the font caching feature is a huge relief from bundling, caching means my internal storage will choke more and i will need device cleaner apps.
    Something like autoclean for cache not used in a while will definitely help more..
    Thanks 👌

  2. They have support for Custom Typefaces as well as downloadable fonts(via a font provider) now! Fonts are a new resourcetype. API 14+.

  3. TextView autosizing: https://youtu.be/V6-roIeNUY0?t=18m44s
    DynamicAnimation: https://youtu.be/V6-roIeNUY0?t=20m17s
    Vector Drawable: https://youtu.be/V6-roIeNUY0?t=23m30s
    Animated Vector Drawable: https://youtu.be/V6-roIeNUY0?t=25m
    Form Factors: https://youtu.be/V6-roIeNUY0?t=30m18s
    Android TV Leanback: https://youtu.be/V6-roIeNUY0?t=31m
    Notable Changes: https://youtu.be/V6-roIeNUY0?t=31m50s
    – CloudDataStore: https://youtu.be/V6-roIeNUY0?t=32m26s
    – FrameMetricsAggregator: https://youtu.be/V6-roIeNUY0?t=33m52s
    – ActionBarDrawableToggle: https://youtu.be/V6-roIeNUY0?t=34m34s

  4. Fonts 06:57

    Sample App

    Public Docs

    Google Fonts Docs

    Google Play Services v11 beta


  5. 7MB for a few emojis?!?! C'mon… This should be solved system wide, instead of every app bundling this lib.

  6. 8:02 when font file is placed in fonts folder as showing in video, it gives error, instead it should be placed in assets/fonts/XXXXXX.ttf

Leave a Reply

Your email address will not be published. Required fields are marked *