35
Globalcode – O Globalcode – O pen4education pen4education Trilha – Mobile Ricardo da Silva Ogliari Desenvolvedor Mobile na FingerTips Desenvolvedor Mobile na FingerTips

Grandes Mentes Pensam Igual

Embed Size (px)

DESCRIPTION

Slides da palestra apresentada no TDC 2012 - São Paulo. O objetivo foi defender a idéia de que as plataformas mais promissoras do momento (iOS, Android e Windows Phone) apresentam muitos conceitos semelhantes. Ou seja, a frase "Mentes Iguais Pensam Igual" também se aplica ao mundo mobile.

Citation preview

Page 1: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Trilha – MobileRicardo da Silva Ogliari

Desenvolvedor Mobile na FingerTipsDesenvolvedor Mobile na FingerTips

Page 2: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Eu

Page 3: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Eu

8 anos de MobilePerto de 150 publicações...

Page 4: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Agenda

IntroduçãoUIInternacionalização - i18nAplicativos nativosPersistência de Dados

Page 5: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Introdução

Passado

Page 6: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Introdução

Presente

Page 7: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Introdução

““Grandes mentes pensam igual”Grandes mentes pensam igual”

Page 8: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Interfaces Gráficas

Drag-and-DropAndroid

Page 9: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Interfaces Gráficas - iOS

http://365cloud.internaldrive.com/2011/10/ios5_simple_xcode_start.jpghttp://365cloud.internaldrive.com/2011/10/ios5_simple_xcode_start.jpg

Page 10: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Interfaces Gráficas - WP

Page 11: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Interfaces Gráficas

http://www.nacionalnet.com.br/portal/img/users/14/Image/espetaculo.jpghttp://www.nacionalnet.com.br/portal/img/users/14/Image/espetaculo.jpg

Page 12: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Introdução

XMLXMLExtensible Markup LanguageExtensible Markup Language

Page 13: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

UI - Android<?<?xmlxml versionversion=="1.0""1.0" encodingencoding=="utf-8""utf-8"?>?><<LinearLayoutLinearLayout xmlns:androidxmlns:android=="http://schemas.android.com/apk/res/andr"http://schemas.android.com/apk/res/android"oid" android:layout_widthandroid:layout_width=="fill_parent""fill_parent" android:layout_heightandroid:layout_height=="fill_parent""fill_parent" >>

<<LinearLayoutLinearLayout android:layout_widthandroid:layout_width=="fill_parent""fill_parent" android:layout_heightandroid:layout_height=="wrap_content""wrap_content" android:backgroundandroid:background=="@drawable/bg_buttons""@drawable/bg_buttons" android:gravityandroid:gravity=="center""center" android:paddingandroid:padding=="10dp""10dp" >>

<<ToggleButtonToggleButton android:idandroid:id=="@+id/mapa_button""@+id/mapa_button" android:layout_widthandroid:layout_width=="wrap_content""wrap_content" android:layout_heightandroid:layout_height=="wrap_content""wrap_content" />/>

<<ToggleButtonToggleButton android:idandroid:id=="@+id/lista_button""@+id/lista_button" android:layout_widthandroid:layout_width=="wrap_content""wrap_content" android:layout_heightandroid:layout_height=="wrap_content""wrap_content" android:checkedandroid:checked=="true""true"

Page 14: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

UI – iOS - Xib<?xml version="1.0" encoding="UTF-8"?><archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">

<data><int key="IBDocument.SystemTarget">1050</int><string key="IBDocument.SystemVersion">9F33</string><string key="IBDocument.InterfaceBuilderVersion">672

</string><string key="IBDocument.AppKitVersion">949.34</string><string key="IBDocument.HIToolboxVersion">352.00

</string><object class="NSMutableArray"

key="IBDocument.EditedObjectIDs"><bool key="EncodedWithXMLCoder">YES</bool><integer value="57"/><integer value="372"/>

</object><object class="NSArray"

key="IBDocument.PluginDependencies"><bool key="EncodedWithXMLCoder">YES</bool><string>com.apple.InterfaceBuilderKit</string><string>com.apple.InterfaceBuilder.CocoaPlugin

</string></object>

Page 15: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Interfaces Gráficas - Xib

Ib = Interface BuilderXcode = xXib

Page 16: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Interfaces Gráficas - xaml<!--LayoutRoot is the root grid where all page content is placed--><!--LayoutRoot is the root grid where all page content is placed--> <<GridGrid x x::NameName="LayoutRoot"="LayoutRoot" Background Background="Transparent">="Transparent"> <!--Pivot Control--><!--Pivot Control--> <<controlscontrols::PivotPivot Title Title="III Fórum Latino Americano">="III Fórum Latino Americano"> <!--Pivot item one--><!--Pivot item one--> <<controlscontrols::PivotItemPivotItem Header Header="Sexta">="Sexta"> <!--Double line list with text wrapping--><!--Double line list with text wrapping--> <<ListBoxListBox x x::NameName="FirstListBox"="FirstListBox" Margin Margin="0,0,-12,0"="0,0,-12,0" ItemsSourceItemsSource="{="{BindingBinding Sexta Sexta}">}"> <<ListBox.ItemTemplateListBox.ItemTemplate>> <<DataTemplateDataTemplate>> <<StackPanelStackPanel Margin Margin="0,0,0,17"="0,0,0,17" Width Width="432"="432" Height Height="78">="78"> <<TextBlockTextBlock Text Text="{="{BindingBinding Evento Evento}"}" TextWrappingTextWrapping="NoWrap"="NoWrap" TextTrimming TextTrimming="WordEllipsis"="WordEllipsis" Style Style="{="{StaticResourceStaticResource PhoneTextExtraLargeStylePhoneTextExtraLargeStyle}"/>}"/> <<TextBlockTextBlock Text Text="{="{BindingBinding Horario Horario}"}" TextWrappingTextWrapping="Wrap"="Wrap" Margin Margin="12,-6,12,0"="12,-6,12,0" Style Style="{="{StaticResourceStaticResource PhoneTextSubtleStylePhoneTextSubtleStyle}"/>}"/> </</StackPanelStackPanel>> </</DataTemplateDataTemplate>> </</ListBox.ItemTemplateListBox.ItemTemplate>> </</ListBoxListBox>> </</controlscontrols::PivotItemPivotItem>>

Page 17: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Interfaces Gráficas - xaml

eXtensible Application Markup LanguageCompetidor do OpenLaszlo do mundo JavaUtilizado pela Microsoft desde o Windows Vista

Page 18: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Internacionalização

AndroidXML com descrição dos textos;Pastas com código do país;Duplicação das pastas e XML´s;Android internacionaliza seu app

Page 19: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Internacionalização

iOSPastas com final lproj

– French.lproj– German.lproj– etc

Dentro da pasta temos um arquivo .string

Page 20: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

InternacionalizaçãoListagem 8. E ng lis h.lp ro j/c o nfig .s tri ng s " P r e f e re n c e s " = " P r e f e re n c e s " ; " W i n d o w " = " W i n d o w " ; " S e s s i o n " = " S e s s i o n " ; " C o l s : " = " C o l s : " ; " R o w s : " = " R o w s : " ; " F o n t " = " F o n t " ; " N o n - A S C I I F o n t " = " N o n-A S C I I F o n t " ; " A n t i - A l i as i n g " = " A n t i- A l i a s i n g " ; " C a n c e l " = " C a n c e l " ; " O K " = " O K " ; " N a m e : " = " N a m e: " ; " E n c o d i n g : " = " E n c o d i n g : " ; " T r a n s p a re n c y : " = " T r an s p a re n c y :" ; " T e x t :" = " T e x t :" ; " S e l e c t i o n : " = " S e l e c t i o n : " ; " B a c k g r o u n d : " = " B a c k g r o u n d : " ; " B o l d : " = " B o l d : " ; " I d l e c h a r a c t e r " = " I d l e c h a ra c t e r" ; " A S C I I c o d e : " = " A S C I I c o d e : " ;

Page 21: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

InternacionalizaçãoListagem 9. F re nc h.lp ro j/c o nfig .s tri ng s " P r e f e re n c e s " = " P r ef e re n c e s " ; " W i n d o w " = " F e n ê t re " ; " S e s s i o n " = " S e s s i o n " ; " C o l s : " = " C o l o n n e s : " ; " R o w s : " = " L i g n e s : " ; " F o n t " = " P o l i c e " ; " N o n - A S C I I F o n t " = " P o l i ce n o n-A S C I I " ; " A n t i - A l i as i n g " = " L i s s a g e d u t e x t e" ; " C a n c e l " = " A n n u l e r " ; " O K " = " O K " ; " N a m e : " = " N o m : " ; " E n c o d i n g : " = " E n c o d a g e : " ; " T r a n s p a re n c y : " = " T r an s p a re n c e : " ; " T e x t : " = " T e x t e : " ; " S e l e c t i o n : " = " Sé l e c t i o n : " ; " B a c k g r o u n d : " = " A r r i è r e- p l a n : " ; " B o l d : " = " G r a s : " ; " I d l e c h a r a c t e r " = " C a r a c t èr e i n ac t i f " ; " A S C I I c o d e : " = " C o d e A S C I I : " ;

Page 22: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Internacionalização

Windows PhoneCriar arquivos .resx

– XMLMesmo nome do arquivo + cultura

– traducao.resx– traducao.pt-BR.resx

Application – Assembly InformationArquivo csproj, editar Supported Cultures

Page 23: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Aplicativos Nativos

AndroidO segredo é a Intent

– Uma ação– Uma URI

Page 24: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Aplicativos Nativos

iOSO segredo é a openURLOs parâmetros definem a ação

Page 25: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Aplicativos Nativos

IOS – Chamar MapaNSString* searchQuery = @"1 Infinite Loop, Cupertino, CA NSString* searchQuery = @"1 Infinite Loop, Cupertino, CA 95014";95014";searchQuery = [addressText searchQuery = [addressText stringByAddingPercentEscapesUsingEncoding: stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];NSUTF8StringEncoding]; NSString* urlString = [NSString NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", stringWithFormat:@"http://maps.google.com/maps?q=%@", searchQuery];searchQuery]; [[UIApplication sharedApplication] openURL:[NSURL [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];URLWithString:urlText]];

Page 26: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Aplicativos Nativos

IOS – Enviar e_mail[[UIApplication sharedApplication] openURL:[NSURL [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]];URLWithString:@"mailto://[email protected]"]];

IOS – IOS – Chamada telefônicaChamada telefônica[[UIApplication sharedApplication] openURL:[NSURL [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://99887766"]];URLWithString:@"tel://99887766"]];

IOS – IOS – Enviar SMSEnviar SMS[[UIApplication sharedApplication] openURL:[NSURL [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:99887766"]];URLWithString:@"sms:99887766"]];

Page 27: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Aplicativos Nativos

Windows PhoneConceito de Launcher e ChooserLauncher – Sem retornoChooser – Com retornoLauncher – TasksDefinir parâmetrosMostrar...

Page 28: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Persistência de Dados

Vários meiosSQLitePar chave-valor

Page 29: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Persistência de Dados

AndroidSharedPreferencesPersiste dados primitivos no formato chave-valor;

– Booleans, floats, int, longs e Strings

1) Instância de SharedPreferences2) Utilizar um dos métodos get: getBoolean, getInt, getFloat...3) Instância de SharedPreferences.Editor4) Utilizar um dos métodos put e depois commit

Page 30: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Persistência de Dados

iOSNSUserDefaults

Page 31: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Persistência de Dados- ( void) insere { 1: NS UserDefaults * objeto = [ NS UserDefaults standardUserDefaults ] ; 2: [objeto setObject: @"http: / / www.mobilidadetudo.com " forKey :@"blog" ] ; 3: [objeto setObject: @"Mobilidade é Tudo" forK ey:@"nomeBlog" ] ; 4: [objeto synchronize] ; } - ( void) recupera { 5: NS UserDefaults * objPrefs = [NS UserDefaults standardUserDefaults]; 6: NS S tr ing * blog = [objPrefs str ingForKey : @"blog"] ; 7: NS S tr ing * nomeBlog = [objPrefs str ingForK ey: @"nomeBlog" ] ; }

Page 32: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Persistência de Dados

Windows PhoneIsolated Storage

Page 33: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Persistência de Dados

Windows PhoneTryGetValueContainsAddSave

Page 34: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

Introdução

““Grandes mentes pensam Grandes mentes pensam igual?”igual?”

Page 35: Grandes Mentes Pensam Igual

Globalcode – OGlobalcode – Open4educationpen4education

PERGUNTAS????

http://www.mobilidadetudo.com@mobilidadetudo

http://itweb.com.br/blog/mobilidade-e-tudo/[email protected]

OBRIGADOOBRIGADO