intervalo técnico - qg mobile

78
QG - Mobile Desafios e Soluções Massilon Gomes Tadeu Marinho Vitor Albuquerque Alex Batista Daniel Herszenhorn Felipe J. Martins Jader Alcântara Marcely Santos

Upload: vitor-albuquerque

Post on 13-Apr-2017

178 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Intervalo Técnico - QG Mobile

QG - Mobile Desafios e Soluções

• Massilon Gomes • Tadeu Marinho • Vitor Albuquerque

• Alex Batista • Daniel Herszenhorn • Felipe J. Martins • Jader Alcântara • Marcely Santos

Page 2: Intervalo Técnico - QG Mobile

Proposta e A&P

Massilon Gomes

Page 3: Intervalo Técnico - QG Mobile

Proposta e A&P

• Cliente: Queiroz Galvão; • Escopo:

• Apontamento Eletrônico (App Android); • Baixa de Eventos App (App Android); • Dashboard (JEE7 e Wildfly);

• Duração: 17 semanas; • Equipe: Gerente de Projetos, Analista de Negócios,

Designer, Arquiteto, 4 Desenvolvedores.

Page 4: Intervalo Técnico - QG Mobile

Proposta e A&P

Planejamento Concepção

Sprints

Design Definição

Webservices

Arquitetura

e BD

Teste Formal Homologação

5 semanas (Apontamento, Baixa de Eventos e Dashboard)

• Planejamento na proposta:

Page 5: Intervalo Técnico - QG Mobile

Proposta e A&P

Planejamento Concepção Design Definição

Webservices

Arquitetura

e BD

6 semanas (Apontamento e Dashboard)

• O que de fato aconteceu:

• Cronograma;

• Riscos;

• ...

• Levantamento de

informações;

• Definição das estórias.

• Wireframe;

• Construção das telas.

Page 6: Intervalo Técnico - QG Mobile

Proposta e A&P

• O que fizemos diferente: • 5 semanas de Analista, Arquiteto e Designer fulltime; • 1 semana no cliente pra levantamento de informações

(GP, Analista, Arquiteto e Designer); • Foco na estabilização dos requisitos; • Foco na definição da Arquitetura da solução; • Foco no Wireframe da aplicação.

Page 7: Intervalo Técnico - QG Mobile

Proposta e A&P

• O que ganhamos: • Maior produtividade no desenvolvimento; • Mais confiança nas decisões sobre a arquitetura da

solução; • Melhor entendimento da necessidade do cliente,

incluindo a usabilidade do aplicativo na obra; • Melhor relacionamento com o cliente.

Page 8: Intervalo Técnico - QG Mobile

O Negócio

Marcely Santos

Page 9: Intervalo Técnico - QG Mobile

O Negócio

• Apontamento Eletrônico: • Permitir o apontamento eletrônico das tarefas executadas

no canteiro de obras através de um Smartphone e/ou Tablet Android.

Page 10: Intervalo Técnico - QG Mobile

O Negócio

• Dashboard:

Page 11: Intervalo Técnico - QG Mobile

O Negócio

• Baixa de Eventos: • Será responsável pela baixa dos eventos executados na

obra através de um Smartphone e/ou Tablet Android.

Page 12: Intervalo Técnico - QG Mobile

UI Experience

Alex Batista

Page 13: Intervalo Técnico - QG Mobile

UI Experience

• Processo de UX; • Métodos utilizados; • Wireframe; • Design;

Page 14: Intervalo Técnico - QG Mobile

UI Experience

• Processo de UX:

Page 15: Intervalo Técnico - QG Mobile

UI Experience

• Métodos: • Entrevista com o usuário; • Cenários; • Personas; • Análise da Tarefa;

Page 16: Intervalo Técnico - QG Mobile

UI Experience

• Métodos: • Entrevista com o usuário; • Cenários; • Personas; • Análise da Tarefa;

Page 17: Intervalo Técnico - QG Mobile

UI Experience

• Wireframe; • Design;

Page 18: Intervalo Técnico - QG Mobile

Contextualização

Tadeu Marinho

Page 19: Intervalo Técnico - QG Mobile

Contextualização

Page 20: Intervalo Técnico - QG Mobile

Contextualização

Page 21: Intervalo Técnico - QG Mobile

REST Client

Tadeu Marinho

Page 22: Intervalo Técnico - QG Mobile

REST Client

Fonte: http://stackoverflow.com/questions/16902716/comparison-of-android-networking-libraries-okhttp-retrofit-volley

Page 23: Intervalo Técnico - QG Mobile

Retrofit

Tadeu Marinho

Page 24: Intervalo Técnico - QG Mobile

Retrofit

• API utilizada como alternativa simples, rápida e eficiente em desenvolvimento da camada de comunicação de aplicações que utilizem padrão REST.

TW Technology Radar Jan 2015

Page 25: Intervalo Técnico - QG Mobile

Retrofit

• Web Client

Page 26: Intervalo Técnico - QG Mobile

Retrofit

• E tem mais ...

Page 27: Intervalo Técnico - QG Mobile

Retrofit

• E tem mais ...

Page 28: Intervalo Técnico - QG Mobile

More... http://square.github.io/retrofit/

http://assets.thoughtworks.com/assets/technology-radar-jan-2015-pt.pdf http://instructure.github.io/blog/2013/12/09/volley-vs-retrofit/

http://stackoverflow.com/questions/16902716/comparison-of-android-networking-libraries-okhttp-retrofit-volley

Retrofit

Page 29: Intervalo Técnico - QG Mobile

SQLite

Tadeu Marinho

Page 30: Intervalo Técnico - QG Mobile

SQLite

• SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine;

• The source code for SQLite is in the public domain; • Development and maintenance of SQLite is sponsored in

part by SQLite Consortium members, including:

A world leader in financial-information technology.

Comprehensive software solutions for Sustaining

Infrastructure.

Working to preserve choice and innovation on

the internet.

Page 31: Intervalo Técnico - QG Mobile

SQLite

• SQL Ansi (PRAGMA foreign_keys=ON)

Page 32: Intervalo Técnico - QG Mobile

SQLite

• Performance inserts:

private void insertOneHundredRecords() {

for (int i = 0; i<100; i++) {

ContentValues values = new ContentValues();

values.put("FirstNumber", i);

values.put("SecondNumber", i);

values.put("Result", i*i);

sampleDB.insert(SAMPLE_TABLE_NAME,null,values);

}

} 1627ms

Page 33: Intervalo Técnico - QG Mobile

SQLite

• Bulk insertion:

private void bulkInsertOneHundredRecords() {

String sql = "INSERT INTO " + SAMPLE_TABLE_NAME + " VALUES (?,?,?);";

SQLiteStatement statement = sampleDB.compileStatement(sql);

sampleDB.beginTransaction();

for (int i = 0; i < 100; i++) {

statement.clearBindings();

statement.bindLong(1, i);

statement.bindLong(2, i);

statement.bindLong(3, i * i);

statement.execute();

}

sampleDB.setTransactionSuccessful();

sampleDB.endTransaction();

} 92ms

Page 34: Intervalo Técnico - QG Mobile

More... https://www.sqlite.org

https://www.sqlite.org/pragma.html#pragma_defer_foreign_keys http://www.techrepublic.com/blog/software-engineer/ turbocharge

-your-sqlite-inserts-on-android/

SQLite

Page 35: Intervalo Técnico - QG Mobile

MVP

Felipe J. Martins

Page 36: Intervalo Técnico - QG Mobile

MVC (Model – Controller - View)

Controller

View Model

S

S = State of the UI

L = UI logic

Acronyms:

L

Page 37: Intervalo Técnico - QG Mobile

MVP (Model – Presenter - View)

View

(XML)

Activity

S L

Exception Handler!

Model

Life Cycle!

Event Handler!

Acronyms: S = State of the UI

L = UI logic

Acronyms:

Page 38: Intervalo Técnico - QG Mobile

View

(Class)

MVP (Model – Presenter - View)

Activity

S

L

Model

View

(XML)

Android API

Exception Handler!

Life Cycle!

Event Handler!

S = State of the UI

L = UI logic

Acronyms:

Page 39: Intervalo Técnico - QG Mobile

Presenter View

(Class)

MVP (Model – Presenter - View)

Activity

S L

Model View

(XML)

Android API

Exception Handler!

Life Cycle!

Event Handler!

S = State of the UI

L = UI logic

Acronyms:

Page 40: Intervalo Técnico - QG Mobile

Activity

Presenter

View Model

MVP (Android)

Page 41: Intervalo Técnico - QG Mobile

Butter Knife View "injection" library for Android

Felipe J. Martins

Page 42: Intervalo Técnico - QG Mobile

Butter Knife Field and method binding for Android views which uses annotation processing to generate boilerplate code for you.

• Eliminate findViewById calls by using @InjectView on fields.

• Eliminate anonymous inner-classes for listeners by annotating methods with @OnClick and others.

Page 43: Intervalo Técnico - QG Mobile

TextView textView1;

textView1 = (TextView) v.findViewById(R.id.textView1);

Toast.makeText(this,textView1.getText(),Toast.LENGTH_SHORT).show();

<TextView

android:id=”@+id/textView1”

android:layout_width=”wrap_content”

android:height=”wrap_content”

android:text=”@string/helloWorld” />

Xml

Java

Butter Knife

Page 44: Intervalo Técnico - QG Mobile

fab = (FloatingActionButton) v.findViewById(R.id.fab);

totalLayout = (LinearLayout) v.findViewById(R.id.totalLayout);

historicoLayout = (LinearLayout) v.findViewById(R.id.historicoLayout);

eventosListView = (ListView) v.findViewById(R.id.eventosListView);

eventoAtualTextView = (TextView) v.findViewById(R.id.eventoAtualTextView);

comecarTempo = (ImageView) v.findViewById(R.id.comecarTempo);

totalHoras = (TextView) v.findViewById(R.id.totalHoras);

terminoHora = (EditText) v.findViewById(R.id.terminoHora);

inicioHora = (EditText) v.findViewById(R.id.inicioHora);

nomeEquipamentoText = (TextView) v.findViewById(R.id.nomeEquipamentoText);

fotoEquipamento = (ImageView) v.findViewById(R.id.fotoEquipamento);

Java Boilerplate code

Butter Knife

Page 45: Intervalo Técnico - QG Mobile

@InjectView(R.id.footer)

TextView footer;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.simple_activity);

ButterKnife.inject(this);

// TODO Use "injected" views...

}

@InjectView

Eliminate findViewById calls by using @InjectView on fields.

Butter Knife

Page 46: Intervalo Técnico - QG Mobile

@OnClick(R.id.submit)

public void submit(View view) {

// TODO submit data to server...

}

@OnClick

public void submit() {

Button submitBtn = (Button) findViewById(R.id.submit);

submitBtn.setOnClickListener(new View.OnClickListener() {

});

// TODO submit data to server...

}

Boilerplate code

Butter Knife

Page 47: Intervalo Técnico - QG Mobile

More... https://github.com/JakeWharton/butterknife

Butter Knife

Page 48: Intervalo Técnico - QG Mobile

Vitor Albuquerque

Envio em Background

Page 49: Intervalo Técnico - QG Mobile

Envio em Background

• Rodar em background; • Enviar apontamentos ao detectar conexão com a

internet; • Enviar os apontamentos esporadicamente (a cada

15 minutos); • Atualizar menu de Enviar Apontamentos após envio

ou falha;

Page 50: Intervalo Técnico - QG Mobile

Vitor Albuquerque

Intent Service

Page 51: Intervalo Técnico - QG Mobile

Intent Service

• Criando um serviço:

Page 52: Intervalo Técnico - QG Mobile

Intent Service

• Chamando um serviço:

Page 53: Intervalo Técnico - QG Mobile

Vitor Albuquerque

AlarmManager

Page 54: Intervalo Técnico - QG Mobile

AlarmManager

• Criando um alarme:

Page 55: Intervalo Técnico - QG Mobile

AlarmManager

• Boas práticas: • Não rodar em horário fixo (ex.: Todos os dias às

12h); • Não acordar o aparelho desnecessariamente; • Evitar criar alarmes baseados em tempos fixos; • Evitar alarmes de alta precisão; • Fazer o SO gerenciar os alarmes;

Page 56: Intervalo Técnico - QG Mobile

Vitor Albuquerque

EventBus Android optimized publish/subscribe event bus

Page 57: Intervalo Técnico - QG Mobile

EventBus

• Como funciona:

Page 58: Intervalo Técnico - QG Mobile

EventBus

• Le código:

Page 59: Intervalo Técnico - QG Mobile

EventBus

• Le código:

Page 60: Intervalo Técnico - QG Mobile

EventBus • Escutando eventos de serviços background (antes)

Page 61: Intervalo Técnico - QG Mobile

EventBus • Resultado da sincronia para a Activity (antes)

Page 62: Intervalo Técnico - QG Mobile

EventBus

• Vocês agora:

Page 63: Intervalo Técnico - QG Mobile

EventBus • Escutando eventos de serviços background

(EventBus)

Page 64: Intervalo Técnico - QG Mobile

EventBus • Escutando eventos de serviços background

(EventBus)

Page 65: Intervalo Técnico - QG Mobile

EventBus

Page 66: Intervalo Técnico - QG Mobile

Saiba mais... https://github.com/greenrobot/EventBus

Page 67: Intervalo Técnico - QG Mobile

Jader Alcântara

NFC Near Field Connection

Page 68: Intervalo Técnico - QG Mobile

Características

• Tecnologia wireless de curta distância (4cm) • Reader/writer mode

• P2P mode (Android Bean) • Card emulation mode

Page 69: Intervalo Técnico - QG Mobile

Utilização no QG

• Processo sem NFC

Page 70: Intervalo Técnico - QG Mobile

Utilização no QG

• Processo com NFC

Page 71: Intervalo Técnico - QG Mobile

Saiba mais... http://nfc-forum.org/

Page 72: Intervalo Técnico - QG Mobile

ZXing Zebra Crossing

Jader Alcântara

Page 73: Intervalo Técnico - QG Mobile

ZXing no QG

public static void irParaLeitorQrCodeBarras(Fragment fragment) {

IntentIntegrator intentIntegrator = IntentIntegrator.forSupportFragment(fragment);

intentIntegrator.setPrompt(fragment.getString(R.string.aponte_qrcode));

intentIntegrator.setOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

intentIntegrator.initiateScan();

}

Java

Page 74: Intervalo Técnico - QG Mobile

Saiba mais... https://github.com/zxing/zxing

Page 75: Intervalo Técnico - QG Mobile

Dashboard

Daniel Herszenhorn

Page 76: Intervalo Técnico - QG Mobile

Características

• WildFly; • Maven; • JEE7; • JSF + Primefaces; • WebSocket;

Page 77: Intervalo Técnico - QG Mobile

Considerações Finais

Tadeu Marinho

Page 78: Intervalo Técnico - QG Mobile

Dúvidas?