Android Tutorial Android 5.0 Information and Resource Thread

Android 5.0 Lollipop is a pretty big update hence the major version number upgrade.
I wanted to make a thread to combine Android 5 SDK related resources since it is such a big update.
At the moment it is a bunch of links, but i will try to sanitize and organize it.

Feel free to add more information, and I will try to add it to the first post.

API Level: 21

Some important changes:
Lollipop uses ART by default which implements Ahead-of-time compilation. Previous versions of ART were buggy so it is worth testing your app on an L device if you can find one.
There are some changes in Notifications, so your notifications will look different on L devices (setColor, Setting up custom sounds, setVisibilty for privacy)
Also getRecentTasks is deprecated (invalidates my MSOS library).

Contents:
  • Major Features
  • New APIs
  • Deprecated APIs
  • Material Design
    • Design Discussion
    • Backporting
  • Backporting/AppCompat
    • Toolbar vs Actionbar
    • Classes in Compatibility Libraries (CardView, RecyclerView)
    • Other third party libs
  • General Resources
  • B4A Libraries and Resources


Major Features

- Material Design
- Notifications (scope/sync)
- OpenGL ES 3.1 + Android Extension Pack
- Camera API + Media Playback + MediaBrowser
- Bluetooth LE Peripheral mode
- Job Scheduler for better power consumption
- App Usage stats

Official Page: http://developer.android.com/about/versions/android-5.0.html
Official Blog: http://android-developers.blogspot.co.uk/2014/10/android-50-lollipop-sdk-and-nexus.html
Full set of changes: http://developer.android.com/sdk/api_diff/21/changes.html
http://www.concretepage.com/android/android-5-lollipop-new-api-feature
http://www.kpbird.com/2014/10/android-50-lollipop-api-change.html




New APIs
Here is a non-exhaustive list of the new apis:
Toolbar: http://developer.android.com/reference/android/widget/Toolbar.html
Camera2: http://developer.android.com/reference/android/hardware/camera2/package-summary.html
JobScheduler: https://developer.android.com/reference/android/app/job/JobScheduler.html
UsageStatsManager: http://developer.android.com/reference/android/app/usage/UsageStatsManager.html
VectorDrawable: http://developer.android.com/reference/android/graphics/drawable/VectorDrawable.html
BitmapDrawable: Theming/tinting: http://developer.android.com/reference/android/graphics/drawable/BitmapDrawable.html
ObjectAnimator: Animating on colors and paths: http://developer.android.com/reference/android/animation/ObjectAnimator.html
StateListAnimator: http://developer.android.com/reference/android/animation/StateListAnimator.html
AnimatedVectorDrawable: http://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html
AnimatedStateListDrawable: http://developer.android.com/reference/android/graphics/drawable/AnimatedStateListDrawable.html
RippleDrawable: http://developer.android.com/reference/android/graphics/drawable/RippleDrawable.html
externalStorage APIs: http://developer.android.com/reference/android/os/Environment.html
MediaCodecs: http://developer.android.com/reference/android/media/MediaCodecList.html
PdfRenderer: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html
TvView: http://developer.android.com/reference/android/media/tv/TvView.html


Deprecated APIs
Non-exhaustive list of deprecated APIs:
(https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q="deprecated in API Level 21" site:developer.android.com)

getRecentTasks and getRunningTasks: Was used to find which apps were on top or were run recently. This library becomes partially deprecated due to this: (http://www.b4x.com/android/forum/th...d-osstats-and-getforegroundapp.34954/#content)
Camera.CameraInfo Camera.Parameters: Deprecated in favor of android.hardware.camera2 API for new applications.
Soundpool: (constructor deprecated) http://developer.android.com/reference/android/media/SoundPool.html
Canvas: (some versions of drawBitmap, clipRegion) : http://developer.android.com/reference/android/graphics/Canvas.html
Actionbar: addTab : http://developer.android.com/reference/android/app/ActionBar.html

Material Design
Material Design is a new design language and guidelines from Google and they are not entirely related to Android, they extend to any platform. Also, refer to Polymer project.

What is different:
Toolbar replaces the actionbar and is now part of the view hierarchy making it flatter down the structure. Also, Toolbar does not have Tabs as the Actionbar used to, so you have to create your own.
NavigationDrawer now slides over the Actionbar/Toolbar since the Toolbar is now part of the view hierarchy.
Depth, items have a depth defined now relative to each other. A shadow is used to pronounce this.
Animations are used much more for e.g. in ripples or navigation drawer indicator.
Touch feedback and ripples, are now used. The buttons are supposed to be lifted up to meet the touch rather than pressed down.
Activity transitions, these are curruntly not available in any form on pre-L devices.

Material Design Specs:
http://www.google.com/design/spec/material-design/introduction.html
Material Design for Android:
http://developer.android.com/training/material/index.html
Holo to material:
https://plus.google.com/103829716466878605055/posts/SWo1dDVsWc5

Official Material Design Blog posts and Checklist (Great for understanding)
Material Design Checklist
Implementing Material Design

Backporting:
Material design with Actionbar (not toolbar): http://xipdev.wordpress.com/2014/10...ion-bar-on-kitkat-and-older-android-versions/
Material Design using Support Libs (Toolbar): https://chris.banes.me/2014/10/17/appcompat-v21/

Backporting and AppCompat

v7 Support Library
appcompat: Actionbar, Toolbar, Material Themes
http://android-developers.blogspot.it/2014/10/appcompat-v21-material-design-for-pre.html
CardView: Flexible layout for presenting information
RecyclerView: Efficiently display large amount of data in a smaller window
gridlayout:
palette: Allows extracting prominent colors from an image to use in your UI

v17 Leanback Library
Build interfaces for TV

Toolbar vs Actionbar:
The Toolbar is a generalization of the Actionbar. However the Toolbar appears in the normal view hierarchy while the Actionbar was a part of the Activity decor.

Yes, we have removed a load of automatic features from the action bar when you use Theme.Material or appcompat:21. Toolbar is a very focused widget which provides it's core 4/5 things only.

For everything else, you now have the tools to easily implement them yourself:

SplitActionBar: Use a Toolbar or ActionMenuView in your layout and position it at the bottom.
Window Progress Bars: Add your own ProgressBar to the Toolbar (it's a ViewGroup remember).
Tabs: Use one of the many libraries available. I even wrote the SlidingTabs sample which you can use.
https://plus.google.com/103829716466878605055/posts/ZqVBYudxvFv


Drawer on Top of AB: http://stackoverflow.com/questions/...y-over-the-actionbar-toolbar-and-under-the-st

Third Party Libs
Group of views:
https://github.com/navasmdc/MaterialDesignLibrary
https://github.com/Micnubinub/MaterialLibrary
https://github.com/keithellis/MaterialWidget
Dialogs:
https://github.com/r0adkll/PostOffice
https://github.com/drakeet/MaterialDialog
Menu/SlidingDrawable:
https://github.com/balysv/material-menu (This is ported but requires slide interaction)
https://github.com/ikimuhendis/LDrawer
Ripple Effect:
https://github.com/balysv/material-ripple
https://github.com/traex/RippleEffect
EditText:
https://github.com/desmondtzq/MaterialEditText (There is a port of this as well)



General Resources



B4A Related Libraries and Threads

Material Theme Porting: http://www.b4x.com/android/forum/threads/material-design.42413/#post-265538
MSMaterialMenu Library: http://www.b4x.com/android/forum/threads/msmaterialmenu-animating-icons.44735/#content
RippleEffect Library: http://www.b4x.com/android/forum/threads/ripple-effect-library.45918/#content
Make B4A Apps Compatible with Android 5: http://www.b4x.com/android/forum/th...e-with-android-5-0-devices.45967/#post-283486
PdfRenderer: https://www.b4x.com/android/forum/threads/pdfrenderer-v0-10-beta.49103/
Material Design Tutorials:
https://www.b4x.com/android/forum/threads/48077/#content
https://www.b4x.com/android/forum/threads/48424/#content
https://www.b4x.com/android/forum/threads/49053/#content
https://www.b4x.com/android/forum/threads/material-design-4-modifyable-and-advanced-menu.49128/
AppCompat Library:
https://www.b4x.com/android/forum/threads/48423/#content
Storage Library:
https://www.b4x.com/android/forum/threads/storage-v1-0.49253/
 
Last edited:

corwin42

Expert
Licensed User
Longtime User
This thread is a great idea. Maybe we can discuss our experiences with the 5.0 SDK and Material Design here.

I just started to have a look at the 5.0 SDK APIs.

As you all know I like to have the standard Android features available in B4A. My first approach to create a Material Design app was to use the appcompat v7 support library and this works so far with one big problem. If you use the designer or add views manually to your activity they won't have the material theme in Android below 5.0. Only if the whole UI is created with xml and the XmlLayoutBuilder library is used all UI elements will have the material design look and feel (though I haven't tested it for now). But this is not the B4A way to create the UI.
Hopefully I will find a solution for this problem.

As an addition to your list of good resources I have found a nice library which has many material design UI components. Maybe it is worth to write a wrapper for this: https://github.com/navasmdc/MaterialDesignLibrary
 

corwin42

Expert
Licensed User
Longtime User
You could also use the guidelines and design your app to make it look like Material design, one example is one of apps, Meme Easy. Pure good ol' B4A :)

Yes, this is of course possible but with this method you will get the "look" but not the "feel" of material design. Material design is much more than a theme and some UI components. The magic is done with lots of small and nice animations like the ripple effects, Activity transition animations etc.
Maybe this can all be done with the normal B4A possibilities but it will be much work and why invent the wheel again if everything is there and just needs some wrapper libraries.
 

corwin42

Expert
Licensed User
Longtime User
Here is a small video of my weather app with some material design elements.


The app uses AppCompat v7 support library. I just updated the support library to v21. Added the nice little arrow drawable to AHNavigationDrawer Library and needed to update the AHSwipeToRefresh library to make it compatible with the new support library.

Overall it took about two hours I think. There is still a problem with the theme. For example checkboxes are completely black so there still is some work to do.
 
Last edited:

thedesolatesoul

Expert
Licensed User
Longtime User
If you use the designer or add views manually to your activity they won't have the material theme in Android below 5.0. Only if the whole UI is created with xml and the XmlLayoutBuilder library is used all UI elements will have the material design look and feel (though I haven't tested it for now). But this is not the B4A way to create the UI.
Hopefully I will find a solution for this problem.
Theming from appcompat only works by intercepting the layout inflation. It doesnt work on views added by code or designer i guess. Infact it doesnt work with views that extend the native views, and all the B4A views are wrapped.
This shouldnt be very hard to do, I believe (hopefully) there will be an update to the support library to do this.

As an addition to your list of good resources I have found a nice library which has many material design UI components. Maybe it is worth to write a wrapper for this: https://github.com/navasmdc/MaterialDesignLibrary
I'll add that to the main post, so someone might port it. There are many libraries on github that do interesting stuff, I was only hoping that we could use native views.

A PDF-renderer? That looks really interesting.
Yes, but it only renders to bitmap to enable zooming etc.

You could also use the guidelines and design your app to make it look like Material design, one example is one of apps, Meme Easy. Pure good ol' B4A :)
Yes, this is one way to do it. So far the only limitation I was was the NavigationDrawer cannot slide over the Actionbar. But you can remove the Actionbar to create your own Toolbar as it is just a group of views.
I have done this, it is a bit of extra work to do with the actionbar libraries and reflection/javaobject. There is also a guide in the first post on how to do some of this.

Yes, this is of course possible but with this method you will get the "look" but not the "feel" of material design. Material design is much more than a theme and some UI components. The magic is done with lots of small and nice animations like the ripple effects, Activity transition animations etc.
Maybe this can all be done with the normal B4A possibilities but it will be much work and why invent the wheel again if everything is there and just needs some wrapper libraries.
Not everything is there. Many of the activity transitions cannot be backported. I dont think the ripple effect is either.


Here is a small video of my weather app with some material design elements.


The app uses AppCompat v7 support library. I just updated the support library to v21. Added the nice little arrow drawable to AHNavigationDrawer Library and needed to update the AHSwipeToRefresh library to make it compatible with the new support library.

Overall it took about two hours I think. There is still a problem with the theme. For example checkboxes are completely black so there still is some work to do.
Looks good! The nice thing of that animation is that it interpolates to how much the drawer is open. I need to figure out how to do that in my alternate library. The one issue again i see in here is that the actionbar is on top of the drawer. You would need to port toolbar to avoid this.
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you for taking the lead on this and sharing the information.
 

b4auser1

Well-Known Member
Licensed User
Longtime User
Also, Toolbar does not have Tabs as the Actionbar used to, so you have to create your own.

http://www.b4x.com/android/forum/threads/actionbar-sliding-pages-tutorial.36865/#content
Does it mean, that StdViewPager can be used,
Dim height AsInt = CalculateHeight(True, True)
vp.Initialize("vp", 3, 100%x, height) 'vp is a StdViewPager objectActivity.AddView(vp.AsView, 0, 0, 100%x, height)'load the pages layoutsvp.Panels(0).LoadLayout("0")
vp.Panels(1).LoadLayout("1")
vp.Panels(2).LoadLayout("2")


but we have to impement own tabs without ActionBar as below ?
bar.Initialize("bar")
bar.NavigationMode = bar.NAVIGATION_MODE_TABS
bar.AddTab("Tab 1")
bar.AddTab("Tab 2")
bar.AddTab("Tab 3")
 

thedesolatesoul

Expert
Licensed User
Longtime User
http://www.b4x.com/android/forum/threads/actionbar-sliding-pages-tutorial.36865/#content
Does it mean, that StdViewPager can be used,
Dim height AsInt = CalculateHeight(True, True)
vp.Initialize("vp", 3, 100%x, height) 'vp is a StdViewPager objectActivity.AddView(vp.AsView, 0, 0, 100%x, height)'load the pages layoutsvp.Panels(0).LoadLayout("0")
vp.Panels(1).LoadLayout("1")
vp.Panels(2).LoadLayout("2")


but we have to impement own tabs without ActionBar as below ?
bar.Initialize("bar")
bar.NavigationMode = bar.NAVIGATION_MODE_TABS
bar.AddTab("Tab 1")
bar.AddTab("Tab 2")
bar.AddTab("Tab 3")
This is only in the case if you are using the Toolbar view (which currently has no B4A port). The StdActionBar is still compatible, if you are continuing with it. I believe the StdViewPager should work with Toolbar, or otherwise we also have AHViewPager.
 
Top