android n highligts

61
#dutahya Android N Highlights!

Upload: sercan-yusuf

Post on 16-Apr-2017

151 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Android N Highligts

#dfkutahya

Android N Highlights!

Page 2: Android N Highligts

#dfkutahya

Sercan Yusuf

Android Developer

GDG Tekirdağ Organizer

@Srcn_ysf

[email protected]

Page 3: Android N Highligts

#dfkutahya

• So many Android N Features

• ConstraintLayout

• Suprise!

• Demo

• How to Implement Some of Them in our App

Page 4: Android N Highligts

#dfkutahya

Multi-Window : Split Screen

android:resizeableActivity=["true" | "false"]

<activity android:name=".MyActivity">     <layout android:defaultHeight="500dp"           android:defaultWidth="600dp"           android:gravity="top|end"           android:minHeight="450dp"           android:minWidth="300dp" /> </activity>

Activity.isInMultiWindowMode()

Activity.onMultiWindowModeChanged()

Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT

Page 5: Android N Highligts

#dfkutahya

Multi-Window : Split Screen Intent intent = new Intent(Intent.ACTION_VIEW);intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);

Page 6: Android N Highligts

#dfkutahya

Drag and Drop

Now between activities!

Page 7: Android N Highligts

#dfkutahya

Drag And Dropandroid.view.DragAndDropPermissions Token object responsible for specifying the permissions granted to the app that receives a drop.

View.startDragAndDrop()

View.DRAG_FLAG_GLOBAL View.DRAG_FLAG_GLOBAL_URI_READ View.DRAG_FLAG_GLOBAL_URI_WRITE

View.cancelDragAndDrop()

View.updateDragShadow()

Activity.requestDragAndDropPermissions() Requests the permissions for the content URIs passed with the ClipData contained in a DragEvent.

Page 8: Android N Highligts

#dfkutahya

Notifications

Page 9: Android N Highligts

#dfkutahya

Notifications• New Templates

Page 10: Android N Highligts

#dfkutahya

Notifications• New Templates

• Bundled Notifications

Page 11: Android N Highligts

#dfkutahya

Notifications• New Templates

• Bundled Notifications

• Direct reply

Page 12: Android N Highligts

#dfkutahya

Required notification contents

A Notification object must contain the following: • A small icon, set by setSmallIcon() • A title, set by setContentTitle() • Detail text, set by setContentText()

Notification.DecoratedCustomViewStyle()

Notification.DecoratedMediaCustomViewStyle()

Builder.setCustomContentView()

Page 13: Android N Highligts

#dfkutahya

Bundled Notifications

ApplicationCompat.Builder.setGroup(String);

Page 14: Android N Highligts

#dfkutahya

Notification priority

Page 15: Android N Highligts

#dfkutahya

Notification priority

NotificationCompat.Builder.setPriority()

PRIORITY_MIN (-2) PRIORITY_MAX (2) PRIORITY_DEFAULT (0)

Page 16: Android N Highligts

#dfkutahya

Quick Settings Tile

Page 17: Android N Highligts

#dfkutahya

Quick Settings Tile

Page 18: Android N Highligts

#dfkutahya

Quick Settings Tile

holds the state of a tile that will be displayed in Quick Settings

•TileServiceprovides the user a tile that can be added to Quick Settings

•Tile

Page 19: Android N Highligts

#dfkutahya

Quick Settings Tile

<service

android:name=".feature.PocketQuickSettingsTileService"

android:icon="@drawable/ic_bookmark"

android:label="@string/unread_articles"

android:permission=“android.permission

.BIND_QUICK_SETTINGS_TILE">

<intent-filter>

<action android:name=“android.service

.quicksettings.action.QS_TILE" />

</intent-filter>

</service>

Page 20: Android N Highligts

#dfkutahya

TileSTATE_ACTIVE

STATE_INACTIVE

STATE_UNAVAILABLE

describeContents()

getContentDescription()

getIcon()

getLabel()

getState()setContentDescription (CharSequence contentDescription)

setLabel(CharSequence label)

setIcon(Icon icon)

setState(int state)

updateTile()

Page 21: Android N Highligts

#dfkutahya

TileService

Page 22: Android N Highligts

#dfkutahya

TileService

Page 23: Android N Highligts

#dfkutahya

TileService

Page 24: Android N Highligts

#dfkutahya

TileService

Page 25: Android N Highligts

#dfkutahya

Doze Mode

Page 26: Android N Highligts

#dfkutahya

Data Saver

Page 27: Android N Highligts

#dfkutahya

ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

if (connMgr.isActiveNetworkMetered()) {

switch (connMgr.getRestrictBackgroundStatus) {

case RESTRICT_BACKGROUND_STATUS_ENABLED: // background data blocked, use less data in foreground

too break;

case RESTRICT_BACKGROUND_STATUS_WHITELISTED: // App should limit usage in fg and bg

break;

case RESTRICT_BACKGROUND_STATUS_DISABLED: // data saver disabled, but still on metered network

break; }

Data Saver

Page 28: Android N Highligts

#dfkutahya

Display Size

Page 29: Android N Highligts

#dfkutahya

Multi Local

• User can select multiple languages

• Order them

• Also added new languages, variants

Page 30: Android N Highligts

#dfkutahya

ACTION_USER_UNLOCKED

Direct Boot

Page 31: Android N Highligts

#dfkutahya

•Scoped Directory Access

•Number Blocking

•Call Screening

• Project Svelte: Background Optimizations

•OpenGL™ ES 3.2 & Vulkan API

Page 32: Android N Highligts

#dfkutahya

ConstraintLayout

Page 33: Android N Highligts

#dfkutahya

ConstraintLayout

● Designed to reduce nesting ● Small - 100 kb ● Compatible since Gingerbread(2.3) (%99.9 percent of

devices) ● First Layout in conjunction with tool (Android Studio) ● Designed to reduce nesting

Page 34: Android N Highligts

#dfkutahya

1. Ensure you have the latest Android Support Repository (version 32 or higher): a. Click Tools > Android > SDK Manager. b. Click the SDK Tools tab. c. Select Android Support Repository, then click OK.

2. Add the Constraint Layout library as a dependency in your build.gradle file: dependencies { compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha5'}

3. In the toolbar or sync notification, click Sync Project with Gradle Files.——

To add a new constraint layout to your project: 1. Right-click on your module's layout directory, then click New > XML > Layout XML. 2. Enter a name for the layout and enter "android.support.constraint.ConstraintLayout" for the Root

Tag. 3. Click Finish.

Page 35: Android N Highligts

#dfkutahya

Page 36: Android N Highligts

#dfkutahya

Page 37: Android N Highligts

#dfkutahya

Creating Manual Constraints

Page 38: Android N Highligts

#dfkutahya

AutoConnect

Page 39: Android N Highligts

#dfkutahya

AutoConnect

Page 40: Android N Highligts

#dfkutahya

Infer Constraints

Page 41: Android N Highligts

#dfkutahya

ConstraintLayout

Page 42: Android N Highligts

#dfkutahya

Layout Inspector

Page 43: Android N Highligts

#dfkutahya

Layout Inspector

Delete Constraint

Positioning the widget relative to constraints

Horizontal - vertical bias

Page 44: Android N Highligts

#dfkutahya

Layout Inspector Inner Dimensions

Wrap Content

Any Size

Fixed

Page 45: Android N Highligts

#dfkutahya

Handling Visibility

Invisible

Gone

Page 46: Android N Highligts

#dfkutahya

constraint_layout_devfest.xml

<ImageView android:src="@android:drawable/btn_star" android:layout_width="0dp" android:layout_height="267dp" android:id="@+id/imageView" android:layout_marginBottom="16dp" android:layout_marginStart="16dp" android:layout_marginTop="16dp" android:layout_marginEnd="16dp" app:layout_constraintLeft_toLeftOf="@+id/constraintLayout" app:layout_constraintTop_toTopOf="@+id/constraintLayout" app:layout_constraintRight_toRightOf="@+id/constraintLayout" app:layout_constraintBottom_toBottomOf="@+id/constraintLayout" tools:layout_constraintLeft_creator="1" tools:layout_constraintTop_creator="1" tools:layout_constraintRight_creator="1" />

standard

already know

important

only for Android Studio

Page 47: Android N Highligts

#dfkutahya

ConstraintLayout Attributes ● layout_constraintTop_toTopOf — Align the top of the desired view to the top of another.

● layout_constraintTop_toBottomOf — Align the top of the desired view to the bottom of another.

● layout_constraintBottom_toTopOf — Align the bottom of the desired view to the top of another.

● layout_constraintBottom_toBottomOf — Align the bottom of the desired view to the bottom of another.

● layout_constraintLeft_toTopOf — Align the left of the desired view to the top of another.

● layout_constraintLeft_toBottomOf — Align the left of the desired view to the bottom of another.

● layout_constraintLeft_toLeftOf — Align the left of the desired view to the left of another.

● layout_constraintLeft_toRightOf — Align the left of the desired view to the right of another.

● layout_constraintRight_toTopOf — Align the right of the desired view to the top of another.

● layout_constraintRight_toBottomOf — Align the right of the desired view to the bottom of another.

● layout_constraintRight_toLeftOf — Align the right of the desired view to the left of another.

● layout_constraintRight_toRightOf — Align the right of the desired view to the right of another.

Page 48: Android N Highligts

#dfkutahya

Demo!!!!

Page 49: Android N Highligts

#dfkutahya

Android Nougat 7.1

Page 50: Android N Highligts

#dfkutahya

Using Static Shortcuts

Page 51: Android N Highligts

#dfkutahya

<manifest xmlns:android="http://schemas.android.com/apk/res/android"              package="com.example.myapplication">   <application ... >     <activity android:name="Main">       <intent-filter>         <action android:name="android.intent.action.MAIN" />         <category android:name="android.intent.category.LAUNCHER" />       </intent-filter>       <meta-data android:name="android.app.shortcuts"                 android:resource="@xml/shortcuts" />     </activity>   </application> </manifest>

Using Static Shortcuts

Page 52: Android N Highligts

#dfkutahya

Page 53: Android N Highligts

#dfkutahya

Using Dynamic Shortcuts

Dynamic shortcuts should provide links to specific, context-sensitive actions within your app. These actions can change between uses of your app, and they can change even while your app is running. Good candidates for dynamic shortcuts include calling a specific person, navigating to a specific location, and viewing the current score for a specific game.

Page 54: Android N Highligts

#dfkutahya

The ShortcutManager API allows you to complete the following operations on dynamic shortcuts:

• Publish: Use setDynamicShortcuts(List) to redefine the entire list of dynamic shortcuts, or use addDynamicShortcuts(List) to augment an existing list of dynamic shortcuts.

• Update: Use the updateShortcuts(List) method.

• Remove: Remove a set of dynamic shortcuts using removeDynamicShortcuts(List), or remove all dynamic shortcuts using removeAllDynamicShortcuts().

Page 55: Android N Highligts

#dfkutahya

Page 56: Android N Highligts

#dfkutahya

Image Keyboard Support

Page 57: Android N Highligts

#dfkutahya

• Enhanced Live Wallpaper Metadata

• Round Icon Resources

When a launcher requests an app icon, the framework returns either android:icon or android:roundIcon, depending on the device build configuration.

Page 58: Android N Highligts

#dfkutahya

• Storage Manager Intent

• Improved VR Thread Scheduling

• Demo User HintApps can now check to see if the device is running as the demo user.

• APIs for Carriers and Calling Apps

• New Screen Densities for Wear Devices

• DENSITY_260

• DENSITY_300

• DENSITY_340

Page 59: Android N Highligts

#dfkutahya

Questions ?

Page 60: Android N Highligts

#dfkutahya

• https://developer.android.com/about/versions/nougat/android-7.0.html

• https://developer.android.com/preview/api-overview.html

• https://www.youtube.com/watch?v=B08iLAtS3AQ&index=5&list=PLOU2XLYxmsILe6_

• https://www.youtube.com/watch?v=sO9aX87hq9c&list=PLWz5rJ2EKKc8jQTUYvIfqA9lMvSGQWtte&index=39

Page 61: Android N Highligts

#dfkutahya

@Srcn_ysf www.srcnysf.com

Teşekkürler!