Share
Embed
Transcript
41 slides
-
Timeline A preview release ~every month Preview 1 Google I/O
2015 Preview 2 July 16th Preview 3 August? Final release Late September -
The New System Low and high risk permission split →
Only if your app targets M Contextualized asking for more Cope with refusal/revocation -
What you get Bluetooth Internet Network State NFC Vibrate Settings
Flashlight Accounts Alarm … As declared in app manifest -
Asking for a cookie if (CheckSelfPermission (this, Manifest.Permission.Camera) != Permission.Granted)
{ if (ShouldShowRequestPermissionRationale (Manifest.Permission.Camera)) Toast.MakeText (/* ... */); RequestPermissions (new string[] { Manifest.Permission.Camera }, RequestCamera); } public override void OnRequestPermissionsResult (int requestCode, string[] permissions, int[] grantResults) { if (requestCode == RequestCamera) { // Handle permission response } } -
Doze Smart detect device inactivity and force shut everything Network
is disabled Wake locks are ignored AlarmManager, Sync, JobScheduler prevented -
App Standby Automatically jail inactive applications Network is disabled Wakeups
are regulated → Unless charging or app deemed used -
Support Design Library Default implementation of Material Support Library Design
Companion to support-v7-appcompat -
NavigationView <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <!-- Content
view --> <android.support.design.widget.NavigationView android:id="@+id/left_drawer" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/drawerheader" app:menu="@menu/drawer_menu" /> </android.support.v4.widget.DrawerLayout> -
NavigationView <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item android:id="@+id/drawer_nav_map" android:checked="true" android:icon="@drawable/ic_drawer_map" android:title="Map"
android:orderInCategory="0" /> <item android:id="@+id/drawer_nav_favorites" android:icon="@drawable/ic_drawer_star" android:title="Favorites" android:orderInCategory="1" /> <item android:id="@+id/drawer_nav_rentals" android:icon="@drawable/ic_drawer_rentals" android:title="Rental History" android:orderInCategory="2" /> </group> </menu> -
CoordinatorLayout <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" />
<!-- ... --> <android.support.design.widget.FloatingActionButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/ic_discuss" android:layout_margin="@dimen/fab_margin" app:layout_anchor="@id/appbar" app:layout_anchorGravity="bottom|right|end" app:layout_behavior="FloatingActionButton.Behavior" /> </android.support.design.widget.CoordinatorLayout> -
Custom behavior public class InfoPaneFabBehavior : CoordinatorLayout.Behavior { // …
public override bool LayoutDependsOn (CoordinatorLayout parent, Java.Lang.Object child, View dependency) { return dependency is InfoPane; } public override bool OnDependentViewChanged (CoordinatorLayout parent, Java.Lang.Object child, View dependency) { // Move the fab vertically to place correctly wrt the info pane var fab = child.JavaCast<SwitchableFab> (); var currentInfoPaneY = ViewCompat.GetTranslationY (dependency); var newTransY = (int)Math.Max (0, dependency.Height - currentInfoPaneY - minMarginBottom - fab.Height / 2); ViewCompat.SetTranslationY (fab, -newTransY); // If alternating between open/closed state, change the FAB face if (wasOpened ^ ((InfoPane)dependency).Opened) { fab.Switch (); wasOpened = !wasOpened; } return true; } } -
M Checklist Think about your permission workflow Be careful that
Doze won’t break your app Consider porting your app to appcompat -
Links Google I/O 2015 talks Permissions youtu.be/f17qe9vZ8RM Material Now youtu.be/8UicJ0SxBwA
Samples github.com/xamarin/monodroid-samples/tree/master/android-m github.com/xamarin/monodroid-samples/tree/master/android5.0/Cheesesquare Blogs android-developers.blogspot.com/2015/05/android-design-support-library.html blog.xamarin.com/add-beautiful-material-design-with-the-android-support-design-library/