Android Development 201

Preview:

DESCRIPTION

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

Citation preview

Android Development 201

Tomáš Kypta

Android Wear

Android Wear

• extension to Android platform

• wearable devices

Android Wear

• UI core functions

• Suggest

• Demand

Android Wear• Suggest: The Context Stream

Android Wear• Demand: The Cue Card

Android Wear

• Developer Preview

• Notifications

• Voice input from a notification

• Notifications with additional pages

Design Patterns

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

• consistent navigation

• important actions

• app identity

ActionBar• navigation up the hierarchy

ActionBar

• can have up to 3 parts

• main action bar

• top bar (tab bar)

• bottom bar

• layout differs for portrait and landscape

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

screen

• displays the app’s main navigation options

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

• provide balanced and aesthetically pleasing layout

Multi-pane layouts• do not forget different orientations

• strategies

• stretch/compress

• adjust the left column width

!

!

• stack

• rearrange the panels

Multi-pane layouts• strategies

• expand/collapse

• show only the most important information in the left panel

!

!

• show/hide

• in portrait behave like phone

Swipe views

Swipe views

• allow efficient navigation between items

• swiping between detail views

• swiping between tabs

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

Swipe-to-dismiss with Undo

Pull-to-refresh

• refresh list by pulling down

• different on Android and iOS

Selection (contextual action bar)

• use long press gesture to select data

• contextual action bar is a temporary action bar

Libraries for Android Development

Libraries

• saves time and work

• it might be painful without libraries

• back-porting new API to older Android versions

• simplifying API

Libraries

• The ideal library?

• “perform one task and perform it well”

• open-source

ActionBar

• ActionBarSherlock

• ActionBarCompat

• support-v7

Dialogs

• Why do we need a library for dialogs?

Dialogs

Dialogs• Let’s simplify

• android-styled-dialogs

Dialogs

• android-styled-dialogs

• backports dialogs in Holo theme

• makes styling and using dialogs a piece of cake

Dialogs

Pull-to-refresh

• ActionBar-PullToRefresh

Navigation Drawer

• DrawerLayour

• support-v4

• SlidingMenu

• android-menudrawer

Swipe views

• ViewPager

• support-v4

Swipe-to-dismiss• Android-SwipeToDismiss

• SwipeToDismissNOA

• backport to Android 2.x

• SwipeToDismissUndoList

• with undo

Networking

• OkHttp

• SPDY support

• Volley

• easier and faster networking

REST API

• retrofit

• simple REST client for Android and Java

Image loaders

• displaying images from web

Image loaders• Volley

• NetworkImageView

• Picasso

• easy to use

• Android-Universal-Image-Loader

• powerful and flexible library

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

Dependency injection

• Dagger

Event bus

• Otto

• Guava based event bus

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

UI debugging• android-grid-wichterle

• app that shows grid overlay

• helps to verify app design

UI debugging

• Scalpel

• debugging tool to uncover the layers under our app

UI niceties

• NineOldAndroids

• backports animation API introduced in Android 3.0

• ViewPagerIndicator

• paging indicator widgets for ViewPager

UI niceties• PagerSlidingTabStrip

Unit testing

• Roboelectric

• fest-android

• FEST assertions geared toward testing Android

Other

• Guava

Developing Libraries

Developing Libraries

• jar

• apklib

• aar

Developing Libraries

• How to publish?

Maven

Maven

• project management tool

• dependency management

Maven

• repositories

• The Central Repository

• local repository

Maven

• Configuration file

• pom.xml

Maven• lifecycle phases

• validate

• compile

• test

• package

• install

• deploy

Maven

• android-maven-plugin

• mvn clean package android:deploy android:run

Gradle

Gradle

• new build system introduced by Google

• DSL

• dependency management through Maven and/or Apache Ivy

ListView & EmptyView

ListView & EmptyView

• How to effectively manage list loading and empty views?

ProGuard

ProGuard

• shrinking

• obfuscation

• optimizing

• repackaging

ProGuard

• build time

• reflection

ProGuard

• Configuration file

• proguard.cfg

ProGuard• output files

• dump.txt

• mapping.txt

• seeds.txt

• usage.txt

ProGuard• Decoding Obfuscated Stack Traces

• ReTrace

ProGuard

• Decoding Obfuscated Stack Traces

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

Android Lint

Android Lint

• static code analysis tool

Android Lint• Correctness

• Security

• Performance

• Usability

• Accessibility

• I18n

Android Lint

• lint path_to_my_project!

• IntelliJ IDEA / Android Studio

• Analyze > Inspect Code …

Android Lint

• lint --check HardcodedText path_to_my_project!

• lint —html lint-report.html path_to_my_project

Android Lint

• Disabling lint checking

• @SupressLint!

• tools:ignore

Android Lint

• Config file

• lint.xml

Android Lint

• custom lint rules

StrictMode

StrictMode

• developer tool for detecting accidental wrong implementation

• detection on current thread

• detection on ony thread

Tools Attributes

Tools Attributes

• tools:ignore!

• @SuppressLint

Tools Attributes

• tools:targetApi!

• @TargetApi

Tools Attributes

• Designtime Layout Attributes

• tools:text!

• tools:visibility!

• etc.

Tools Attributes

• tools:locale

Tools Attributes

• tools:context

Tools Attributes

• tools:layout

Tools Attributes

• tools:listitem!

• tools:listheader!

• tools:listfooter

Traceview

Context

Context

• interface to global information about an application environment

Context• Types

• Application

• Activity/Service

• BroadcastReceiver

• ContentProvider

Context & Singletons

• Use only application context for singletons

Context & UI

• Use only activity context

THE END

Recommended