[android-developers] Seeking layout advice

2014-04-04 Thread Simon Giddings
I am working on an application where the user can create a list of items 
(songs).
The user can also add a text block to the list - text to be read as an 
introduction to the next sequence of songs, for example.

It is with this text editer activity that I am having trouble deciding 
where to put things.
I am displaying it as a dialog and have therefore placed cancel and ok 
buttons at the bottom of the layout.
However, this means that they are hidden by the virtual keyboard when the 
focus is on the edittext widget.

In addition, I wanted to add the ability to paste text copied from 
elsewhere - another app, a web page.

After having looked in the design guides ... I am no further forward.

Should I rather be placing the cancel and ok buttons at the top of the 
layout ?
Should this rather be a full screen activity where I use the action bar to 
place a paste button ?
If I do this, should the cancel and ok buttons also be in the action bar ?

I hope someone can advise me with this as I am stuck at this point.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Best low-end test devices?

2014-04-04 Thread Rich
What are some recommendations for good devices to test for users on the 
lower end of the price, quality, and screen resolution/density scale?  My 
every day workflow is to test on Nexus 5 and Galaxy S3, and my coworkers 
cover a lot of other high end phones (LG G2, Galaxy S4, Nexus 4).  I'd love 
to see what everything looks like on a lower end screen but on a device 
that still represents what real users would have.  According to Flurry, 99% 
of my users on the main app I work on are all on high end devices (with 
greater than 500k users, mostly in US and AUS).

Thanks,

Rich

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: How to inject mock objects in Android?

2014-04-04 Thread Rich
I created a class that I call ServiceLocator that allows me to do 
lightweight dependency injection (as opposed to using a heavy library that 
requires annotation and/or reflection).

You can declare interfaces for things that you need mocked, register them 
with their proper implementations in your Application.onCreate, but then in 
your unit tests re-register those interfaces to the mock objects.  I've 
found that when I need to wait for Application.onCreate to finish in my 
unit tests, I derive them from ActivityTestCase and call 
getInstrumentation().waitForIdleSync();

Here's my class - you can copy it, or use the library it's in if you'd like.
https://github.com/aguynamedrich/beacon-utils/blob/master/Library/src/us/beacondigital/utils/ServiceLocator.java

in Application.onCreate, you'd do

ServiceLocator.register(FooInterface.class, FooImplementation.class);

And in your unit test setup, you'd do

ServiceLocator.register(FooInterface.class, MockFooImpl.class);

Then, in your code, you'd resolve your interfaces with

ServiceLocator.resolve(FooInterface.class);

Documented roughly here:
https://github.com/aguynamedrich/beacon-utils#to-use-servicelocator-as-a-dependency-container

On Sunday, March 23, 2014 9:37:13 PM UTC-7, Yuvi wrote:


  Hi,
 
 I am facing issue while unit testing :

 // Service class that have to be tested.

 class FooService extends Service{

 public static FooService sFooService;

 private Bar mBar = new Bar();
 //Other private objects

 @Override
 protected void onCreate()
 {
 sFooService = this;
 }

 public static FooService getInstance()
 {
 return sFooService;
 }

 @Override
 protected void onDestroy()
 {
 sFooService = null;
 }

 public void doSomething()
 {
 //do Some stuff here
 if(done)
 {
 mBar.perfomAction(true);
 // Now this performAction method doing many stuffs using some 
 other classes
 // that may have dependency and initialized from some else. Hence 
 throwing exceptions.
 // Therefore need to mock Bar class. but how ??
 }
 else
 {
 mBar.perfomAction(false);
 }
 }}


 // Test Class

 class FooTest extends ServiceTestCaseFooService{

 protected void setUp() throws Exception
 {
 super.setUp();
 MockitoAnnotations.initMocks(this);
 startService(new Intent(getContext(), FooService.class));

 }

 protected void tearDown() throws Exception
 {
 super.tearDown();
 }

 public void testdoSomething()
 {
 Bar bar = mock(bar.class);
 doThrow(new RuntimeException re).when(bar).performAction(true);

 //How to inject bar mocked object?

 assertNotNull(FooService.getInstance());

 try
 {
 FooService.getInstance().doSomeThing();
 Assert.Fail(Runtime exception should be thrown);
 }
 catch (RuntimeException re)
 {

 }
 }}


 Now, here how can I inject bar mocked object which is created using 
 Mockito ?

 I have googled this, and found that some guys suggested to create getter 
 and setter for Bar class. Which I don't think is a valid solution, because 
 there could be number of private object, that will be visible to outside 
 FooService class.

 Regards,

 Yuvi



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Seeking layout advice

2014-04-04 Thread Rich
I think that if you're worried about the soft keyboard covering your 
buttons, it'd be best to move from a dialog to a full screen activity.  
What I do to get around the soft keyboard covering my buttons at the bottom 
of an activity is to put all of the content inside of a ScrollView except 
for the bottom buttons.  That way when the soft keyboard collapses part of 
the layout, it (as far as I can tell from my own test devices) doesn't 
cover the action buttons.  You can also use an ActionBar button for the 
save action and use the back button as cancel (probably a better design 
than mine).  The Google apps usually have a checkbox in the ActionBar for 
Save and consider that back button as the intention to cancel the action.

On Friday, April 4, 2014 5:59:43 AM UTC-7, Simon Giddings wrote:

 I am working on an application where the user can create a list of items 
 (songs).
 The user can also add a text block to the list - text to be read as an 
 introduction to the next sequence of songs, for example.

 It is with this text editer activity that I am having trouble deciding 
 where to put things.
 I am displaying it as a dialog and have therefore placed cancel and ok 
 buttons at the bottom of the layout.
 However, this means that they are hidden by the virtual keyboard when the 
 focus is on the edittext widget.

 In addition, I wanted to add the ability to paste text copied from 
 elsewhere - another app, a web page.

 After having looked in the design guides ... I am no further forward.

 Should I rather be placing the cancel and ok buttons at the top of the 
 layout ?
 Should this rather be a full screen activity where I use the action bar to 
 place a paste button ?
 If I do this, should the cancel and ok buttons also be in the action bar ?

 I hope someone can advise me with this as I am stuck at this point.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.