android n highligts

Post on 16-Apr-2017

151 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

#dfkutahya

Android N Highlights!

#dfkutahya

Sercan Yusuf

Android Developer

GDG Tekirdağ Organizer

@Srcn_ysf

srcnysf@gmail.com

#dfkutahya

• So many Android N Features

• ConstraintLayout

• Suprise!

• Demo

• How to Implement Some of Them in our App

#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

#dfkutahya

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

#dfkutahya

Drag and Drop

Now between activities!

#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.

#dfkutahya

Notifications

#dfkutahya

Notifications• New Templates

#dfkutahya

Notifications• New Templates

• Bundled Notifications

#dfkutahya

Notifications• New Templates

• Bundled Notifications

• Direct reply

#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()

#dfkutahya

Bundled Notifications

ApplicationCompat.Builder.setGroup(String);

#dfkutahya

Notification priority

#dfkutahya

Notification priority

NotificationCompat.Builder.setPriority()

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

#dfkutahya

Quick Settings Tile

#dfkutahya

Quick Settings Tile

#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

#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>

#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()

#dfkutahya

TileService

#dfkutahya

TileService

#dfkutahya

TileService

#dfkutahya

TileService

#dfkutahya

Doze Mode

#dfkutahya

Data Saver

#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

#dfkutahya

Display Size

#dfkutahya

Multi Local

• User can select multiple languages

• Order them

• Also added new languages, variants

#dfkutahya

ACTION_USER_UNLOCKED

Direct Boot

#dfkutahya

•Scoped Directory Access

•Number Blocking

•Call Screening

• Project Svelte: Background Optimizations

•OpenGL™ ES 3.2 & Vulkan API

#dfkutahya

ConstraintLayout

#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

#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.

#dfkutahya

#dfkutahya

#dfkutahya

Creating Manual Constraints

#dfkutahya

AutoConnect

#dfkutahya

AutoConnect

#dfkutahya

Infer Constraints

#dfkutahya

ConstraintLayout

#dfkutahya

Layout Inspector

#dfkutahya

Layout Inspector

Delete Constraint

Positioning the widget relative to constraints

Horizontal - vertical bias

#dfkutahya

Layout Inspector Inner Dimensions

Wrap Content

Any Size

Fixed

#dfkutahya

Handling Visibility

Invisible

Gone

#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

#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.

#dfkutahya

Demo!!!!

#dfkutahya

Android Nougat 7.1

#dfkutahya

Using Static Shortcuts

#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

#dfkutahya

#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.

#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().

#dfkutahya

#dfkutahya

Image Keyboard Support

#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.

#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

#dfkutahya

Questions ?

#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

#dfkutahya

@Srcn_ysf www.srcnysf.com

Teşekkürler!

top related