Showing posts with label fragments. Show all posts
Showing posts with label fragments. Show all posts

Tuesday, 29 October 2013

Droidcon 2013: Responsive Design for Android

Juhani Lehtimäki, Smashing Android UI

Presentation available online

  • alternative to master/detail — grid view
    • works the same way with adapters
    • can adjust number of columns in values to adjust on screen size
    • use it as an easy way to extend the UI without a huge redesign
    • also useful for inspiring designers to take the design further
  • need to figure out where the relayout/break points are?
    • need to talk about what is the screen size for this layout to work
    • don’t need to talk about tablets or phones
  • juhani likes to do the large screen first
    • makes you think about whole picture if there would be enough space
  • android design in action from google
    • different layers of design:
    • information design — all you
    • interaction design — all holo/android
      • 100% chance users use other Android apps
      • tiny chance they use other platforms
      • optimise for user experience, not app consistency across platforms
    • visual design — mixed
  • use the default components!
    • but don’t components that are not needed for the app
  • action bar gives you lots of things for free
    • adjusts for screen space automatically
    • components work across lots of devices — tested!
    • also hold down item gives tooltip
  • best app for design on android right now: timely alarm clock
    • and follows all android guidelines!
  • can fade out the action bar when content scrolls up
  • use Android Asset Studio to show how 9 patch graphics work
    • designers can check online
  • use fragments from support package even when targetting 4+
  • decouple front end from backend
  • when fragment starts it queries for data by id
    • fragment should ask for it
    • manager should respond to bus with id when ready
    • fragment subscribes when it’s around and unsubscribes when it goes away
    • so fragment can then request data when it’s told that id is ready
  • http://jimulabs.com — lets you change layouts on the fly
  • make sure your design team uses android devices
    • at least for a couple of weeks!
  • use standard components and follow guidelines
    • won’t just cost in coding — think about all the testing!
  • think scalable from the first wireframe

Droidcon 2013: Boundbox & Memento + Annotation Processing

Stéphane Nicolas, Octo Technology

Matthias Käppler, Soundcloud @mttkay

boundbox

Slides available online

https://github.com/stephanenicolas/boundbox

  • break encapsulation to ease testing (with Android in mind)
  • let’s you access things from Android SDK that you wouldn’t normally access
  • also lets you add fields (e.g. for stub Android jars that only have methods available)
  • can indicate how far up the hierarchy you want to expose
  • don’t need to change your code — just adjust your tests
  • access using reflection, but access checked at compile time
  • open source on github
  • compares with WhiteBox from PowerMock
  • intended for helping test UI layer
    • find views by field name
    • invoke methods & inner classes directly
    • faster and more direct than robotium & UIAutomator
    • as fast as espresso

memento

https://github.com/mttkay/memento

  • dealing with keeping state when the screen rotates
  • the activity gets destroyed and recreated and all your state is thrown away…
  • can use onRetainNonConfigurationInstance to pass objects through configuration changes
    • but what if you need to retain more than one object
    • deprecated in place of fragments — these keep their configuration using setRetainInstance
    • but watch out: setRetainInstance doesn’t work for child fragments and is super-prone for data leaks
  • but what if you have multiple fragments sharing the same state?
  • mark a package private field as @Retain
  • override the new onLaunch method (used to indicate first time initialisation of the class i.e. not after a config change)
  • then use Memento.retain(this)

annotation processing in general

  • use JavaWriter from squareup
  • look at how square does it for dagger dependency injection
  • Google has a library so you can assert over java source files
    • lets you compile with a processor and check the output
  • want to split up the annotation processor into two:
    • one for the client-side annotation itself and any required classes
    • one for the processor (don’t want it in your app)