SlideShare a Scribd company logo
www.immobilienscout24.de




The Multi-Device Nightmare
- and how to clear the Elm Street

Droidcon | Berlin | 09.03.2013 | Hasan Hosgel
About me


             Hasan Hosgel


             Twitter:              @alosdev
             Github:               alosdev
             Google+:              Hasan Hosgel
             Slideshare: hosgel


             developer @ ImmobilienScout24
             CO-Organizer @ GDG Android in
             Berlin
             & community events




           Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Fragmentation




                Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Fragmentation




     > 2700 Android Devices




                Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Here comes The Nightmare




Image source:                                          Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
http://www.flickr.com/photos/boogeyman13/4553188509/
Here comes The Nightmare




                               For developers

Image source:                                          Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
http://www.flickr.com/photos/boogeyman13/4553188509/
Device Classification




Images sources:                         Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
https://play.google.com/store/devices
Device Classification




Images sources:                         Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
https://play.google.com/store/devices
http://www.htc.com/de/
Device Classification




Images sources:                    Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
http://www.sony.de/hub/google-tv
Device Classification




Images Sources                Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
https://developer.ford.com/
Resource Folders


You can use several qualifiers in the resource folders name for serving
the best matching resource. Most used qualifiers:

●   Language (-en)
●   Language & Region (-en-rUS)
●   Smallest Width (-swXXXdp, e.g. –sw600dp)
●   Screensize (-small, -normal, -large)
●   Screen Orientation (-port, -land)
●   Screen Pixel Densitiy (-mdpi, -hdpi, -xhdpi, -xxhdpi)
●   Platform Version (-v11, -v13)




                                        Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Resource Folders


If you have several resource folders, the one with the greatest
matching number qualifiers will be used. e.g. :

1.   res/values/strings.xml
2.   res/values-en-rUS/strings.xml
3.   res/values-large/strings.xml
4.   res/values-sw600dp/strings.xml




                                      Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Resource Folders


If you have several resource folders, the one with the greatest
matching number qualifiers will be used. e.g. :

1.   res/values/strings.xml
2.   res/values-en-rUS/strings.xml
3.   res/values-large/strings.xml
4.   res/values-sw600dp/strings.xml

If two resources have the same number of matching qualifiers, the
ordering in the previous slide will rank the qualifiers.

e.g. Device configurations:
Nexus One: 1.
Galaxy Tab 7.0 in German: 3.
Nexus 7: 4.



                                      Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Images


●   Use the different qualifiers for the screen pixel density (mdpi, hdpi,
    etc.)
●   If you are forced to use text on images use language and region
    (en, es-rUs, en-rUS, etc.)
●   Better approach is to use 9-patch drawables, which stretches
    automatically depending on the content inside.
       More about it: developer.android.com
●   You must provide different launcher icons for Froyo, Honeycomb
    and above? Use the platform version. (v4, v11, v14)




                                      Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Classifications For Layouts


If your minimum SDK is at least platform version 13 (Honeycomb MR2)


project-folder/res/
   layout/                         small phones
   layout-sw320dp/                 other phones
   layout-sw600dp/                 tablets 7”
   layout-sw720dp/                 tablets 10”




You should also use orientation


                                    Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Classifications For Layouts


If your minimum SDK is lower than platform version 11 (Honeycomb)
project-folder/res/
   layout/                        phones
   layout-v11/                    tablets 10”
   layout-v13/                    small phones
   layout-sw320dp/                other phones
   layout-sw600dp/                tablets 7”
   layout-sw720dp/                tablets 10”


The smallest width qualifier gets automatically platform version “v13”
through the packager, for avoiding problems with the number of
matching qualifiers.
You can also use the screen size qualifier, if you want to reach
small, medium and large screens previous to Honeycomb.


                                    Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Classifications In Code


You can read the configurations from the device.

Smarter Approach: use boolean resources

project-folder/res/values/layouts.xml
<resources>
   <bool name="is_phone_small”>false</bool>
   <bool name="is_phone_other">true</bool>
   <bool name="is_tablet_7”>false</bool>
   <bool name="is_tablet_10”>false</bool>
</resources>




                                   Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Classifications In Code


You can read the configurations from the device.

Smarter Approach: use boolean resources

project-folder/res/values/layouts.xml
<resources>
   <bool name="is_phone_small”>false</bool>
   <bool name="is_phone_other">true</bool>
   <bool name="is_tablet_7”>false</bool>
   <bool name="is_tablet_10”>false</bool>
</resources>

Usage in code:
Context.getResources().getBoolean(R.bool.is_phone_small)




                                   Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Current Layout File Structure


project-folder/res/
   layout/main.xml
   layout-v11/main.xml
   layout-v13/main.xml
   layout-sw320dp/main.xml
   layout-sw600dp/main.xml
   layout-sw720dp/main.xml




                             Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Current Layout File Structure


project-folder/res/
   layout/main.xml
   layout-v11/main.xml
   layout-v13/main.xml
   layout-sw320dp/main.xml
   layout-sw600dp/main.xml
   layout-sw720dp/main.xml


     Fixing one bug in the 10“ layout has to be done in two files.




                                   Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Current Layout File Structure


project-folder/res/
   layout/main.xml
   layout-v11/main.xml
   layout-v13/main.xml
   layout-sw320dp/main.xml
   layout-sw600dp/main.xml
   layout-sw720dp/main.xml


     Fixing one bug in the 10“ layout has to be done in two files.
      error prone




                                   Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Resource Alias


1. Put your layout files in the default folder.

    project-folder/res/
        layout/main.xml
        layout/main_phone_other.xml
        layout/main_tablet_7.xml
        layout/main_tablet_10.xml




                                      Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Resource Alias


1. Put the needed layout files in the default folder.

    project-folder/res/
        layout/main.xml
        layout/main_phone_other.xml
        layout/main_tablet_7.xml
        layout/main_tablet_10.xml

2. Declare another resource file in the values folder and create an item
   with the needed classification.

    project-folder/res/values-sw600dp/layouts.xml
        <item name=“main” type=“layout”>@layout/main_tablet7</item>




                                     Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Sample Screen




                Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Sample Screen




                       Use <includes>

                Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Sample Screen

                   Create custom view




                       Use <includes>

                Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Custom View
public class CustomView extends LinearLayout {
  public CustomView(Context context, AttributeSet attrs) {
    super(context, attrs);
    LayoutParams lp = …
    addView(getText(context, "label"), lp);
    addView(getText(context, "value"), lp);
    if (context.getResources().getBoolean(R.bool.is_phone) ||
       context.getResources().getBoolean(R.bool.is_phone_other)) {
        setOrientation(VERTICAL);
    } else {
       setOrientation(HORIZONTAL);
    }
}
    private TextView getText(Context context, String text) {
      TextView textView = new TextView(context);
      textView.setText(text);
      return textView;
    }
}
                                   Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Sample Screen

                   Create custom view




                       Use <includes>

                Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Sample Screen

                          Create custom view




      If custom view has much more
      business logic and need lifecycles
       Create a Fragment




                              Use <includes>

                       Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Custom XML Attribute (attrs.xml)

<resources>
 <declare-styleable name=”CustomView">
    <attr name="label" format="reference|string" />
    <attr name="value" format="reference|string" />
    <attr name="orientation" format="enum">
      <enum name="horizontal" value="0" />
      <enum name="vertical" value="1" />
    </attr>
  </declare-styleable>
<resources>




                                 Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Custom XML Attribute (main.xml)

Add to root XML node
xmlns:app="http://schemas.android.com/apk/res/de.alosdev"

Usage in custom view

<de.alosdev.CustomView
    android:id="@+id/customView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:label="label 1"
    app:orientation="vertical"
    app:value="value 1" />




                                 Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Custom XML Attribute (CustomView.java)

public class CustomView extends LinearLayout {
static final int[] ORIENTATION = new int[] { HORIZONTAL, VERTICAL
};
   public CustomView(Context context, AttributeSet attrs) {
     super(context, attrs);
        …
        TypedArray a = context.obtainStyledAttributes(attrs,
           R.styleable.CustomView);
     try {
       setOrientation(ORIENTATION[
          a.getInt(R.styleable.CustomView_orientation, 0)]);
     } finally {
        a.recycle();
     }
  }
    …
}
                                 Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Best Practices
which learned painfully



●   You have already an application
       Remove orientation fixation and suppressing of orientation
       change from manifest to avoid long bug analyzing.
●   You start from the scratch
       Focus on main classification for faster time to market
         But create an overall concept for better modularization
●   If you support both orientations, save the instance state while
    orientation changes for more responsiveness
       Especially for states, need a long computation for creation.
       Make the state object Parcelable for faster write & read




                                      Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Mission Accomplished




http://www.flickr.com/photos/ianaberle/5729561934/   Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Mission Accomplished




http://www.flickr.com/photos/ianaberle/5729561934/   Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
Q&A




                                                                                                              Page 36
Source: http://www.flickr.com/photos/21496790@N06/5065834411/   Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
www.immobilienscout24.de


Thanks for your attention!

Contact:

Hasan Hosgel               Multidevice Nightmare
Twitter: @alosdev          Repo:        https://github.com/alosdev/multidevice-nightmare-demo
Github: alosdev            SlideShare: http://de.slideshare.net/hosgel/droidcon-2013-multidevice-nightmare

More Related Content

Similar to Droidcon 2013 Multidevice Nightmare

Mtc spring 2014 best practices to develop for different android device classi...
Mtc spring 2014 best practices to develop for different android device classi...Mtc spring 2014 best practices to develop for different android device classi...
Mtc spring 2014 best practices to develop for different android device classi...
Hasan Hosgel
 
Multi Screen Hell
Multi Screen HellMulti Screen Hell
Multi Screen Hell
Abdullah Çetin ÇAVDAR
 
AdaptTo 2013 Device Detection with Apache DeviceMap
AdaptTo 2013 Device Detection with Apache DeviceMapAdaptTo 2013 Device Detection with Apache DeviceMap
AdaptTo 2013 Device Detection with Apache DeviceMap
Conrad Woeltge
 
AdaptTo 2013: Slinging multichannel content the BrowserMap way / Device Detec...
AdaptTo 2013: Slinging multichannel content the BrowserMap way / Device Detec...AdaptTo 2013: Slinging multichannel content the BrowserMap way / Device Detec...
AdaptTo 2013: Slinging multichannel content the BrowserMap way / Device Detec...
Andrew Savory
 
Android Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoTAndroid Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoT
inovex GmbH
 
Going to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific LanguagesGoing to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific Languages
Guillaume Laforge
 
Get ready for new nexus devices
Get ready for new nexus devicesGet ready for new nexus devices
Get ready for new nexus devices
Ketan Raval
 
[Ultracode Munich #4] Short introduction to the new Android build system incl...
[Ultracode Munich #4] Short introduction to the new Android build system incl...[Ultracode Munich #4] Short introduction to the new Android build system incl...
[Ultracode Munich #4] Short introduction to the new Android build system incl...
BeMyApp
 
Extending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScriptExtending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScript
Roy Clarkson
 
The specs behind the sex, mobile-friendly layout beyond the desktop
The specs behind the sex, mobile-friendly layout beyond the desktopThe specs behind the sex, mobile-friendly layout beyond the desktop
The specs behind the sex, mobile-friendly layout beyond the desktop
betabeers
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips
Kenichi Kambara
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and Drush
Pantheon
 
Jenkins entwined with deployment and pragmatism
Jenkins entwined with deployment and pragmatismJenkins entwined with deployment and pragmatism
Jenkins entwined with deployment and pragmatism
Eric Ritchie
 
Android TCJUG
Android TCJUGAndroid TCJUG
Android TCJUG
Justin Grammens
 
Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012
Guillaume Laforge
 
Drupal as a Framework for Mobile Development
Drupal as a Framework for Mobile DevelopmentDrupal as a Framework for Mobile Development
Drupal as a Framework for Mobile Development
Rachel Jaro
 
Android Development project
Android Development projectAndroid Development project
Android Development project
Minhaj Kazi
 
Exploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaExploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molina
Salvador Molina (Slv_)
 
Best Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue SolutionsBest Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue Solutions
RapidValue
 
Pinkoi Mobile Web
Pinkoi Mobile WebPinkoi Mobile Web
Pinkoi Mobile Web
mikeleeme
 

Similar to Droidcon 2013 Multidevice Nightmare (20)

Mtc spring 2014 best practices to develop for different android device classi...
Mtc spring 2014 best practices to develop for different android device classi...Mtc spring 2014 best practices to develop for different android device classi...
Mtc spring 2014 best practices to develop for different android device classi...
 
Multi Screen Hell
Multi Screen HellMulti Screen Hell
Multi Screen Hell
 
AdaptTo 2013 Device Detection with Apache DeviceMap
AdaptTo 2013 Device Detection with Apache DeviceMapAdaptTo 2013 Device Detection with Apache DeviceMap
AdaptTo 2013 Device Detection with Apache DeviceMap
 
AdaptTo 2013: Slinging multichannel content the BrowserMap way / Device Detec...
AdaptTo 2013: Slinging multichannel content the BrowserMap way / Device Detec...AdaptTo 2013: Slinging multichannel content the BrowserMap way / Device Detec...
AdaptTo 2013: Slinging multichannel content the BrowserMap way / Device Detec...
 
Android Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoTAndroid Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoT
 
Going to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific LanguagesGoing to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific Languages
 
Get ready for new nexus devices
Get ready for new nexus devicesGet ready for new nexus devices
Get ready for new nexus devices
 
[Ultracode Munich #4] Short introduction to the new Android build system incl...
[Ultracode Munich #4] Short introduction to the new Android build system incl...[Ultracode Munich #4] Short introduction to the new Android build system incl...
[Ultracode Munich #4] Short introduction to the new Android build system incl...
 
Extending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScriptExtending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScript
 
The specs behind the sex, mobile-friendly layout beyond the desktop
The specs behind the sex, mobile-friendly layout beyond the desktopThe specs behind the sex, mobile-friendly layout beyond the desktop
The specs behind the sex, mobile-friendly layout beyond the desktop
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and Drush
 
Jenkins entwined with deployment and pragmatism
Jenkins entwined with deployment and pragmatismJenkins entwined with deployment and pragmatism
Jenkins entwined with deployment and pragmatism
 
Android TCJUG
Android TCJUGAndroid TCJUG
Android TCJUG
 
Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012
 
Drupal as a Framework for Mobile Development
Drupal as a Framework for Mobile DevelopmentDrupal as a Framework for Mobile Development
Drupal as a Framework for Mobile Development
 
Android Development project
Android Development projectAndroid Development project
Android Development project
 
Exploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaExploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molina
 
Best Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue SolutionsBest Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue Solutions
 
Pinkoi Mobile Web
Pinkoi Mobile WebPinkoi Mobile Web
Pinkoi Mobile Web
 

Recently uploaded

Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 

Recently uploaded (20)

Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 

Droidcon 2013 Multidevice Nightmare

  • 1. www.immobilienscout24.de The Multi-Device Nightmare - and how to clear the Elm Street Droidcon | Berlin | 09.03.2013 | Hasan Hosgel
  • 2. About me Hasan Hosgel Twitter: @alosdev Github: alosdev Google+: Hasan Hosgel Slideshare: hosgel developer @ ImmobilienScout24 CO-Organizer @ GDG Android in Berlin & community events Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 3. Fragmentation Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 4. Fragmentation > 2700 Android Devices Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 5. Here comes The Nightmare Image source: Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel http://www.flickr.com/photos/boogeyman13/4553188509/
  • 6. Here comes The Nightmare For developers Image source: Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel http://www.flickr.com/photos/boogeyman13/4553188509/
  • 7. Device Classification Images sources: Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel https://play.google.com/store/devices
  • 8. Device Classification Images sources: Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel https://play.google.com/store/devices http://www.htc.com/de/
  • 9. Device Classification Images sources: Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel http://www.sony.de/hub/google-tv
  • 10. Device Classification Images Sources Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel https://developer.ford.com/
  • 11. Resource Folders You can use several qualifiers in the resource folders name for serving the best matching resource. Most used qualifiers: ● Language (-en) ● Language & Region (-en-rUS) ● Smallest Width (-swXXXdp, e.g. –sw600dp) ● Screensize (-small, -normal, -large) ● Screen Orientation (-port, -land) ● Screen Pixel Densitiy (-mdpi, -hdpi, -xhdpi, -xxhdpi) ● Platform Version (-v11, -v13) Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 12. Resource Folders If you have several resource folders, the one with the greatest matching number qualifiers will be used. e.g. : 1. res/values/strings.xml 2. res/values-en-rUS/strings.xml 3. res/values-large/strings.xml 4. res/values-sw600dp/strings.xml Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 13. Resource Folders If you have several resource folders, the one with the greatest matching number qualifiers will be used. e.g. : 1. res/values/strings.xml 2. res/values-en-rUS/strings.xml 3. res/values-large/strings.xml 4. res/values-sw600dp/strings.xml If two resources have the same number of matching qualifiers, the ordering in the previous slide will rank the qualifiers. e.g. Device configurations: Nexus One: 1. Galaxy Tab 7.0 in German: 3. Nexus 7: 4. Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 14. Images ● Use the different qualifiers for the screen pixel density (mdpi, hdpi, etc.) ● If you are forced to use text on images use language and region (en, es-rUs, en-rUS, etc.) ● Better approach is to use 9-patch drawables, which stretches automatically depending on the content inside. More about it: developer.android.com ● You must provide different launcher icons for Froyo, Honeycomb and above? Use the platform version. (v4, v11, v14) Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 15. Classifications For Layouts If your minimum SDK is at least platform version 13 (Honeycomb MR2) project-folder/res/ layout/  small phones layout-sw320dp/  other phones layout-sw600dp/  tablets 7” layout-sw720dp/  tablets 10” You should also use orientation Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 16. Classifications For Layouts If your minimum SDK is lower than platform version 11 (Honeycomb) project-folder/res/ layout/  phones layout-v11/  tablets 10” layout-v13/  small phones layout-sw320dp/  other phones layout-sw600dp/  tablets 7” layout-sw720dp/  tablets 10” The smallest width qualifier gets automatically platform version “v13” through the packager, for avoiding problems with the number of matching qualifiers. You can also use the screen size qualifier, if you want to reach small, medium and large screens previous to Honeycomb. Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 17. Classifications In Code You can read the configurations from the device. Smarter Approach: use boolean resources project-folder/res/values/layouts.xml <resources> <bool name="is_phone_small”>false</bool> <bool name="is_phone_other">true</bool> <bool name="is_tablet_7”>false</bool> <bool name="is_tablet_10”>false</bool> </resources> Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 18. Classifications In Code You can read the configurations from the device. Smarter Approach: use boolean resources project-folder/res/values/layouts.xml <resources> <bool name="is_phone_small”>false</bool> <bool name="is_phone_other">true</bool> <bool name="is_tablet_7”>false</bool> <bool name="is_tablet_10”>false</bool> </resources> Usage in code: Context.getResources().getBoolean(R.bool.is_phone_small) Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 19. Current Layout File Structure project-folder/res/ layout/main.xml layout-v11/main.xml layout-v13/main.xml layout-sw320dp/main.xml layout-sw600dp/main.xml layout-sw720dp/main.xml Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 20. Current Layout File Structure project-folder/res/ layout/main.xml layout-v11/main.xml layout-v13/main.xml layout-sw320dp/main.xml layout-sw600dp/main.xml layout-sw720dp/main.xml Fixing one bug in the 10“ layout has to be done in two files. Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 21. Current Layout File Structure project-folder/res/ layout/main.xml layout-v11/main.xml layout-v13/main.xml layout-sw320dp/main.xml layout-sw600dp/main.xml layout-sw720dp/main.xml Fixing one bug in the 10“ layout has to be done in two files.  error prone Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 22. Resource Alias 1. Put your layout files in the default folder. project-folder/res/ layout/main.xml layout/main_phone_other.xml layout/main_tablet_7.xml layout/main_tablet_10.xml Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 23. Resource Alias 1. Put the needed layout files in the default folder. project-folder/res/ layout/main.xml layout/main_phone_other.xml layout/main_tablet_7.xml layout/main_tablet_10.xml 2. Declare another resource file in the values folder and create an item with the needed classification. project-folder/res/values-sw600dp/layouts.xml <item name=“main” type=“layout”>@layout/main_tablet7</item> Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 24. Sample Screen Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 25. Sample Screen Use <includes> Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 26. Sample Screen Create custom view Use <includes> Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 27. Custom View public class CustomView extends LinearLayout { public CustomView(Context context, AttributeSet attrs) { super(context, attrs); LayoutParams lp = … addView(getText(context, "label"), lp); addView(getText(context, "value"), lp); if (context.getResources().getBoolean(R.bool.is_phone) || context.getResources().getBoolean(R.bool.is_phone_other)) { setOrientation(VERTICAL); } else { setOrientation(HORIZONTAL); } } private TextView getText(Context context, String text) { TextView textView = new TextView(context); textView.setText(text); return textView; } } Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 28. Sample Screen Create custom view Use <includes> Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 29. Sample Screen Create custom view If custom view has much more business logic and need lifecycles  Create a Fragment Use <includes> Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 30. Custom XML Attribute (attrs.xml) <resources> <declare-styleable name=”CustomView"> <attr name="label" format="reference|string" /> <attr name="value" format="reference|string" /> <attr name="orientation" format="enum"> <enum name="horizontal" value="0" /> <enum name="vertical" value="1" /> </attr> </declare-styleable> <resources> Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 31. Custom XML Attribute (main.xml) Add to root XML node xmlns:app="http://schemas.android.com/apk/res/de.alosdev" Usage in custom view <de.alosdev.CustomView android:id="@+id/customView" android:layout_width="wrap_content" android:layout_height="wrap_content" app:label="label 1" app:orientation="vertical" app:value="value 1" /> Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 32. Custom XML Attribute (CustomView.java) public class CustomView extends LinearLayout { static final int[] ORIENTATION = new int[] { HORIZONTAL, VERTICAL }; public CustomView(Context context, AttributeSet attrs) { super(context, attrs); … TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomView); try { setOrientation(ORIENTATION[ a.getInt(R.styleable.CustomView_orientation, 0)]); } finally { a.recycle(); } } … } Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 33. Best Practices which learned painfully ● You have already an application Remove orientation fixation and suppressing of orientation change from manifest to avoid long bug analyzing. ● You start from the scratch Focus on main classification for faster time to market But create an overall concept for better modularization ● If you support both orientations, save the instance state while orientation changes for more responsiveness Especially for states, need a long computation for creation. Make the state object Parcelable for faster write & read Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 34. Mission Accomplished http://www.flickr.com/photos/ianaberle/5729561934/ Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 35. Mission Accomplished http://www.flickr.com/photos/ianaberle/5729561934/ Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 36. Q&A Page 36 Source: http://www.flickr.com/photos/21496790@N06/5065834411/ Droidcon 2013 | Mutli-Device Nightmare | Hasan Hosgel
  • 37. www.immobilienscout24.de Thanks for your attention! Contact: Hasan Hosgel Multidevice Nightmare Twitter: @alosdev Repo: https://github.com/alosdev/multidevice-nightmare-demo Github: alosdev SlideShare: http://de.slideshare.net/hosgel/droidcon-2013-multidevice-nightmare