android development 201

96
Android Development 201 Tomáš Kypta

Upload: tomas-kypta

Post on 27-Jan-2015

104 views

Category:

Technology


0 download

DESCRIPTION

Lecture about some advanced themes in Android development. Faculty of Informatics, Masaryk University, 2014

TRANSCRIPT

Page 1: Android Development 201

Android Development 201

Tomáš Kypta

Page 2: Android Development 201

Android Wear

Page 3: Android Development 201

Android Wear

• extension to Android platform

• wearable devices

Page 4: Android Development 201
Page 5: Android Development 201
Page 6: Android Development 201
Page 7: Android Development 201

Android Wear

• UI core functions

• Suggest

• Demand

Page 8: Android Development 201

Android Wear• Suggest: The Context Stream

Page 9: Android Development 201

Android Wear• Demand: The Cue Card

Page 10: Android Development 201

Android Wear

• Developer Preview

• Notifications

• Voice input from a notification

• Notifications with additional pages

Page 11: Android Development 201

Design Patterns

Page 12: Android Development 201

ActionBar• dedicated piece of UI at the top of each screen

• consistent navigation

• important actions

• app identity

Page 13: Android Development 201

ActionBar• navigation up the hierarchy

Page 14: Android Development 201

ActionBar

• can have up to 3 parts

• main action bar

• top bar (tab bar)

• bottom bar

• layout differs for portrait and landscape

Page 15: Android Development 201

Navigation Drawer• panel that transitions from the left edge of the

screen

• displays the app’s main navigation options

Page 16: Android Development 201

Multi-pane layouts• many different screen sizes and types of devices

• provide balanced and aesthetically pleasing layout

Page 17: Android Development 201

Multi-pane layouts• do not forget different orientations

• strategies

• stretch/compress

• adjust the left column width

!

!

• stack

• rearrange the panels

Page 18: Android Development 201

Multi-pane layouts• strategies

• expand/collapse

• show only the most important information in the left panel

!

!

• show/hide

• in portrait behave like phone

Page 19: Android Development 201

Swipe views

Page 20: Android Development 201

Swipe views

• allow efficient navigation between items

• swiping between detail views

• swiping between tabs

Page 21: Android Development 201

Swipe-to-dismiss• dismiss list item by swiping left or right

Page 22: Android Development 201

Swipe-to-dismiss with Undo

Page 23: Android Development 201

Pull-to-refresh

• refresh list by pulling down

• different on Android and iOS

Page 24: Android Development 201

Selection (contextual action bar)

• use long press gesture to select data

• contextual action bar is a temporary action bar

Page 25: Android Development 201

Libraries for Android Development

Page 26: Android Development 201

Libraries

• saves time and work

• it might be painful without libraries

• back-porting new API to older Android versions

• simplifying API

Page 27: Android Development 201

Libraries

• The ideal library?

• “perform one task and perform it well”

• open-source

Page 28: Android Development 201

ActionBar

• ActionBarSherlock

• ActionBarCompat

• support-v7

Page 29: Android Development 201

Dialogs

• Why do we need a library for dialogs?

Page 30: Android Development 201

Dialogs

Page 31: Android Development 201

Dialogs• Let’s simplify

• android-styled-dialogs

Page 32: Android Development 201

Dialogs

• android-styled-dialogs

• backports dialogs in Holo theme

• makes styling and using dialogs a piece of cake

Page 33: Android Development 201

Dialogs

Page 34: Android Development 201

Pull-to-refresh

• ActionBar-PullToRefresh

Page 35: Android Development 201

Navigation Drawer

• DrawerLayour

• support-v4

• SlidingMenu

• android-menudrawer

Page 36: Android Development 201

Swipe views

• ViewPager

• support-v4

Page 37: Android Development 201

Swipe-to-dismiss• Android-SwipeToDismiss

• SwipeToDismissNOA

• backport to Android 2.x

• SwipeToDismissUndoList

• with undo

Page 38: Android Development 201

Networking

• OkHttp

• SPDY support

• Volley

• easier and faster networking

Page 39: Android Development 201

REST API

• retrofit

• simple REST client for Android and Java

Page 40: Android Development 201

Image loaders

• displaying images from web

Page 41: Android Development 201

Image loaders• Volley

• NetworkImageView

• Picasso

• easy to use

• Android-Universal-Image-Loader

• powerful and flexible library

Page 42: Android Development 201

View injection• getting rid of boilerplate code

• TextView title = (TextView) findViewById(R.id.title);!

• Butter Knife

• @InjectView(R.id.title) TextView title;!

• can’t be used in libraries

Page 43: Android Development 201

Dependency injection

• Dagger

Page 44: Android Development 201

Event bus

• Otto

• Guava based event bus

Page 45: Android Development 201

IntelliJ IDEA plugins• android-selector-chapek

• generates drawable selectors from appropriately named Android resources

• android-butterknife-zelezny

• allows one-click creation of Butterknife view injections

Page 46: Android Development 201

UI debugging• android-grid-wichterle

• app that shows grid overlay

• helps to verify app design

Page 47: Android Development 201

UI debugging

• Scalpel

• debugging tool to uncover the layers under our app

Page 48: Android Development 201

UI niceties

• NineOldAndroids

• backports animation API introduced in Android 3.0

• ViewPagerIndicator

• paging indicator widgets for ViewPager

Page 49: Android Development 201

UI niceties• PagerSlidingTabStrip

Page 50: Android Development 201

Unit testing

• Roboelectric

• fest-android

• FEST assertions geared toward testing Android

Page 51: Android Development 201

Other

• Guava

Page 52: Android Development 201

Developing Libraries

Page 53: Android Development 201

Developing Libraries

• jar

• apklib

• aar

Page 54: Android Development 201

Developing Libraries

• How to publish?

Page 55: Android Development 201

Maven

Page 56: Android Development 201

Maven

• project management tool

• dependency management

Page 57: Android Development 201

Maven

• repositories

• The Central Repository

• local repository

Page 58: Android Development 201

Maven

• Configuration file

• pom.xml

Page 59: Android Development 201

Maven• lifecycle phases

• validate

• compile

• test

• package

• install

• deploy

Page 60: Android Development 201

Maven

• android-maven-plugin

• mvn clean package android:deploy android:run

Page 61: Android Development 201

Gradle

Page 62: Android Development 201

Gradle

• new build system introduced by Google

• DSL

• dependency management through Maven and/or Apache Ivy

Page 63: Android Development 201

ListView & EmptyView

Page 64: Android Development 201

ListView & EmptyView

• How to effectively manage list loading and empty views?

Page 65: Android Development 201

ProGuard

Page 66: Android Development 201

ProGuard

• shrinking

• obfuscation

• optimizing

• repackaging

Page 67: Android Development 201

ProGuard

• build time

• reflection

Page 68: Android Development 201

ProGuard

• Configuration file

• proguard.cfg

Page 69: Android Development 201

ProGuard• output files

• dump.txt

• mapping.txt

• seeds.txt

• usage.txt

Page 70: Android Development 201

ProGuard• Decoding Obfuscated Stack Traces

• ReTrace

Page 71: Android Development 201

ProGuard

• Decoding Obfuscated Stack Traces

• retrace.sh -verbose mapping.txt obfuscated_stacktrace.txt

Page 72: Android Development 201

Android Lint

Page 73: Android Development 201

Android Lint

• static code analysis tool

Page 74: Android Development 201

Android Lint• Correctness

• Security

• Performance

• Usability

• Accessibility

• I18n

Page 75: Android Development 201

Android Lint

• lint path_to_my_project!

• IntelliJ IDEA / Android Studio

• Analyze > Inspect Code …

Page 76: Android Development 201

Android Lint

• lint --check HardcodedText path_to_my_project!

• lint —html lint-report.html path_to_my_project

Page 77: Android Development 201

Android Lint

• Disabling lint checking

• @SupressLint!

• tools:ignore

Page 78: Android Development 201

Android Lint

• Config file

• lint.xml

Page 79: Android Development 201

Android Lint

• custom lint rules

Page 80: Android Development 201

StrictMode

Page 81: Android Development 201

StrictMode

• developer tool for detecting accidental wrong implementation

• detection on current thread

• detection on ony thread

Page 82: Android Development 201

Tools Attributes

Page 83: Android Development 201

Tools Attributes

• tools:ignore!

• @SuppressLint

Page 84: Android Development 201

Tools Attributes

• tools:targetApi!

• @TargetApi

Page 85: Android Development 201

Tools Attributes

• Designtime Layout Attributes

• tools:text!

• tools:visibility!

• etc.

Page 86: Android Development 201

Tools Attributes

• tools:locale

Page 87: Android Development 201

Tools Attributes

• tools:context

Page 88: Android Development 201

Tools Attributes

• tools:layout

Page 89: Android Development 201

Tools Attributes

• tools:listitem!

• tools:listheader!

• tools:listfooter

Page 90: Android Development 201

Traceview

Page 91: Android Development 201

Context

Page 92: Android Development 201

Context

• interface to global information about an application environment

Page 93: Android Development 201

Context• Types

• Application

• Activity/Service

• BroadcastReceiver

• ContentProvider

Page 94: Android Development 201

Context & Singletons

• Use only application context for singletons

Page 95: Android Development 201

Context & UI

• Use only activity context

Page 96: Android Development 201

THE END