Posts

  • Generate JUnit assertions from your JSON

    Got some JSON you want to build into a model and test?

    It can be pretty tedious writing all of that code. Instead, why not generate the assert* code automatically? I've been writing code manually for a while now and finally decided to build something to write that boilerplate code for me.

    I've put up a live version for anyone to use, as well as open-sourced it on GitHub. Let me know what you think!

    Here's some JSON to test with:

    {
         "id": 2,
         "name": "An ice sculpture",
         "price": 12.50,
         "tags": ["cold", "ice"],
         "dimensions": {
             "length": 7.0,
             "width": 12.0,
             "height": 9.5
         },
         "warehouse_location": {
             "latitude": -78.75,
             "longitude": 20.4
         }
     }
    
  • Android Animations: Bring Your Application to Life

    My Animation talk from Droidcon New York City 2014

    Video:

  • Wi-Fi issues on Moto X 2nd Gen

    I received my 2nd Gen Moto X today. During setup, I attempted to connect to our company's Wi-Fi network to no avail. I was able to connect to another public Wi-Fi in the area but for some reason not to our typical Cisco WAP setup at work. All of the other devices we have at work are able to connect to the network, so I'm not sure what is going on.

    I've contacted Motorola customer support, supplied a logcat output of the Wi-Fi-related messages during the connection attempt, but they were not immediately able to resolve the issue. Instead, they've gathered my information and will be reaching out to me after escalating the issue internally.

    I'll follow up more here as this issue and hopefully resolution progresses.

    UPDATE 1 [2014-09-26T14:30:00EST]: Motorola has called me back and are currently connecting me to their "level 2 support". I'm on hold now waiting for them to chime in. Will update more as this progresses.

    UPDATE 2 [2014-09-26T14:40:00EST]: Motorola got back on the phone with me and explained that their level 2 support is currently swamped and that they have my information and will call me in the next 24 hours.

    In the meantime, I'll just blow through my carrier data allocation as I install all of my apps again (because I had to reset my phone to see if that'd solve the problem).

    UPDATE 3 [2014-09-27T14:07:00EST]: Someone by the name of 'Matt' followed up on this blog in the comments to ask me to bring the conversation to email. So, I did. The conversation so far is as follows:

    Me to them

    From: Dallas Gutauckis <[redacted]>
    Date: Fri, Sep 26, 2014 at 11:37 PM
    Subject: Re: http://dallasgutauckis.com/2014/09/26/wi-fi-issues-on-moto-x-2nd-gen/#comments
    To: supportforums@motorola.com

    Hi,

    Someone naming himself Matt commented on my blog post about the Wi-Fi issue some users are having with their 2nd Gen Moto X asking me to reach out. I already have an ongoing support issue ([redacted]) where I also already shared logcat output — not much but all I could give.

    Let me know if there is something else I can provide to get this matter resolved expediently.

    Best,
    Dallas

    Them to me

    From: Motorola Support Forums <[redacted]>
    Date: Sat, Sep 27, 2014 at 10:00 AM
    Subject: Re: http://dallasgutauckis.com/2014/09/26/wi-fi-issues-on-moto-x-2nd-gen/#comments
    To: Dallas Gutauckis <[redacted]>

    Hi Dallas.

    Have you updated your router software? The Wifi team says old software versions of Cisco APs have problem with PMF supported devices. Cisco fixed this issue in later software versions.

    Let me know if that helps. Thanks.

    • Matt

    Matt and Mark
    Social Media - Customer Care
    Motorola Mobility
    Visit us at https://forums.motorola.com

    Me to them

    From: Dallas Gutauckis <[redacted]>
    Date: Sat, Sep 27, 2014 at 2:06 PM
    Subject: Re: http://dallasgutauckis.com/2014/09/26/wi-fi-issues-on-moto-x-2nd-gen/#comments
    To: Motorola Support Forums <[redacted]>

    Matt,

    I'm unaware of whether the AP is up to date, and unfortunately, I'm not going to be able to simply try to update the routers because we don't employ any full-time IT staff capable of managing the routers — this would instead require we pay a contractor to come in and ensure they're up-to-date, something I'm not willing to do if we can't be sure it's the problem.

    I know of other people having the issue — they might be able to check such a thing on their network. See https://twitter.com/cavega_/status/515566709927706624

    What I still don't understand is why this is a 2nd-Gen-specific issue and not 1st-Gen. I realize they're different devices, and potentially different networking hardware, but I would assume if it can work on one, it can work on the other.

    Not yet sure where this is going to get us…

    UPDATE 4 [~2014-09-27T9:00:00EST]: Got a call that went to voicemail (because I was still asleep). The caller said they were just checking in on me to see if my issue was fixed or not. If it wasn't, they gave me the number to contact their level 1 support (seems I've been downgraded). Obviously, nothing has changed, so nothing is resolved. Note that this call came in before the email response from Matt.

    UPDATE 5 [2014-10-07T19:30:00EST]: Our IT contractor happened to need to come in to set up network redundancy for our internet connection, at which time we also asked him to update the Cisco controller. The update seems to have fixed the PMF as suggested by Motorola support. Quick! Call your IT gang out to update your controllers. Best of luck to all. Still a ridiculously shitty experience to have for a new device [where they know it's going to be broken for users].

  • Android Animation — Bringing Your Applications to Life @ Droidcon NYC 2014

    Last weekend, I gave a talk on animation on Android at the innaugural Droidcon NYC (2014). The talk was well-received and I got some tough questions. Nonetheless, I'm happy I did it and I'm posting the presentation for your viewing pleasure. I highly recommend checking out the actual Keynote file (linked to from the Speakerdeck site) if you can as it includes the videos/animations as opposed to just static images.

    speakerdeck

    You can check out all of my presentations (regardless of how old they are) at /about/presentations/

  • Android Authority: Best resources for Android development

    Whether you’re a seasoned professional or just beginning with Android development, this list of resources (including tools, libraries, and blogs) is useful for any developer or team on just about any project, big or small.

    Read more: Best resources for Android development

  • Listing connected Android devices with OS version and model

    I was wandering down the path of trying to associate the myriad of devices connected to my machine for debugging. I wanted to know very easily what the devices' model and OS version were without having to manual check by disconnecting and reconnecting devices and using the process of elimination.

    One way to see this information is using a special flag with adb:

    adb devices -l
    

    This yields something like

    List of devices attached
    
    HT16JHX24920 device usb:14130000  
    
    015d2a506750081b device usb:14120000 product:nakasi model:Nexus_7 device:grouper  
    
    4d005e148cc950eb device usb:14112000 product:ja3gub model:GT_I9500 device:ja3g  
    
    0A3BC06A11010002 device usb:14140000  
    
    e08b84fd device usb:14113000  
    
    HT346W912280 device usb:14114000  
    

    Which as you can probably tell doesn't give us all of the information we want, nor does it seem to work on every device.

    So instead, I wrote a script for printing out what I needed. The bash script reads properties from the device via adb shell.

    The output for that looks like:

        HT16JHX24920 [ 4.0.3]: PG86100  
    
    015d2a506750081b [ 4.4.2]: Nexus 7  
    
    4d005e148cc950eb [   4.3]: GT-I9500  
    
    0A3BC06A11010002 [ 4.1.2]: DROID RAZR  
    
            e08b84fd [ 4.1.1]: SAMSUNG-SGH-I747  
    
        HT346W912280 [ 4.1.2]: HTC One  
    

    View, download, or fork the script

    In case you were curious, the corresponding properties are:

    $ adb shell getprop ro.product.model  
    
    PG86100  
    

    and

    $ adb -s HT16JHX24920 shell getprop ro.build.version.release
    
    4.0.3
    
  • Making Borders for Views Using layer-list

    Android is full of many ways to do things differently. One of those things happens to be making a border for a View.

    The common approach I've seen is for developers to have two Views. One View is the View with a background (be it solid, bitmap, or otherwise). The other View acts as a border, typically either 1px or 1dp in width or height, the other side matching the height or width of the other View. Although this is certainly an easy approach, at adds more to your layout than is likely necessary.

    Example with Views:

    <View
        android:layout_width="match_parent"
        android:layout_height="1px"
        android:background="#ccc" /></p>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#eee"
        android:text="Hello, World" />
    

    Assuming those Views are encapsulated in a LinearLayout with vertical orientation, you'll end up with a TextView with background of #eee and top border of #ccc.

    Now, let me introduce you to layer-list

    layer-list allows you to do many things regarding multiple drawables. One of the more common implementations is adding a border to something.

    I'll explain by example:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape>
                <solid android:color="#ccc" />
            </shape>
        </item>
        <item android:top="1px">
            <shape>
                <solid android:color="#eee" />
            </shape>
        </item>
    </layer-list>
    

    What this example shows is the layer-list way of going about the previous example. This will produce a drawable that has a 1px solid top border colored #ccc and a background of #eee. The confusing part to this for most people tends to be where the 1px is designated. layer-list draws top-down in the XML. This means that #ccc is drawn in the full background first, and then #eee is drawn over top of that, with a 1px top offset.

  • A Better Parcelabler...

    A little bit ago (okay, a long time ago) I wrote a blog post about a tool I wrote for creating Parcelable implementations for Android. At time of writing, I knew it wasn't a great solution, but that at least it worked... Since then, I constantly put off writing what I thought would be a better solution: an IDE plugin.

    So last week, I embarked upon the journey of making a plugin for Android Studio. I immediately saw that something existed, but it was a bit older, and not quite as feature-packed as I had hoped. So, I took it upon myself to make some enhancements and submit a pull request.

    I'll be continuing development under my fork, where you'll always be able to grab the latest as I work on enhancements. Please feel free to fork and submit pull requests as well.

    Check out the plugin...

  • Moving to New Opportunities, New Things, New York...

    Over six-and-a-half years ago, I joined a small startup, MeetMe (then myYearbook), of around 20 or 30 employees in the small, artsy town of New Hope, PA. Over the years, MeetMe provided me with many opportunities to grow and learn, allowing me to transition from a full stack web engineer to an Android engineer. I truly am grateful not only for the opportunities that I've been given, but also for the team that I've gotten to work with.

    But then, there is change. I've decided to make a transition and move on to new opportunities. I can't express how excited I am to transition to my new role as the lead Android engineer for SeatGeek, a search engine of sorts for finding great tickets to events -- be it sports, theater, music, or otherwise.

    I'm excited for all of the new challenges I'll face working with the SeatGeek team, and I wish all of the best to the MeetMe team as they continue to help the world meet new and interesting people.

  • Android Animation: Bringing Your Application to Life

    At MeetMe, we have a yearly internal conference wherein we invite folks internal and external to speak to the team (en masse & in breakouts) about emerging technology, trends, core company bits, etc. My core focus this year has been about spicing up our Android applications through exceptional UI/UX specifically using the grace and beauty of animations. As they say, sharing is caring, and I want everyone else to have access... so please, take a look through my presentation. If you have feedback, questions, hate mail, or anything else -- please comment below.

    Screen Shot 2013-12-31 at 17.15.49

    https://speakerdeck.com/dallasgutauckis/android-animation

  • Android: putting a ViewPager inside a ListView

    So, I've been Googling for a while to find a clean, reasonable approach for putting a ViewPager inside of a ListView (or any vertically scrolling element). The problem with putting a ViewPager inside a ListView is that it takes only a small amount of vertical (Y) delta before the ListView begins to consume touch events instead of delegating to the child in order to enable the scrolling of the ListView. That's fine, but the problem often occurs after the ViewPager has already started processing a page change (when dragging horizontally), producing a poor user experience resulting in the improper pagination and scrolling of the two views.

    There are a few ways to try to handle this.

    1. You could not do it at all (thanks Dianne and Mark)
    2. You can set a touch listener on the ListView and try to delegate the touches based on which view you think needs to get the touches and what actions need to occur based on those touches.
    3. You can also combine a touch listener with GestureDetector to try to make the implementation a little less cumbersome. The problem is that in some ListViews, our layouts are a little more complex than single item rows of text. If the item layout has for instance a Button, we'd then need to properly delegate the touch event down to the Button. This obviously has huge ramifications for implementation and testing.

    In order to avoid the aforementioned shenanigans, I added an OnPageChangeListener to the ViewPager and based on the state of the pager, forced a touch delegate from the Activity.

    Contrived example:

    class MyActivity extends Activity {  
    
        private ViewPager mViewPager;  
    
        private View mTouchTarget;
    
        @Override
        protected void onCreate(Bundle icicle) {  
    
            super.onCreate(icicle);  
    
            setContentView(R.layout.example);
            mViewPager = (ViewPager) findViewById(R.id.view_pager);
            mViewPager.setOnPageChangeListener(new OnPageChangeListener() {
                private int mPreviousState = ViewPager.SCROLL_STATE_IDLE;
    
                @Override
                public void onPageSelected(int position) {  
                    // NO-OP
                }
    
                @Override  
                public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {  
                    // NO-OP
                }
    
                @Override
                public void onPageScrollStateChanged(int state) {
                    // All of this is to inhibit any scrollable container from consuming our touch events as the user is changing pages
                    if (mPreviousState == ViewPager.SCROLL_STATE_IDLE) {
                        if (state == ViewPager.SCROLL_STATE_DRAGGING) {
                            mTouchTarget = mViewPager;
                        }
                    } else {
                        if (state == ViewPager.SCROLL_STATE_IDLE || state == ViewPager.SCROLL_STATE_SETTLING) {
                            mTouchTarget = null;
                        }
                    }
    
                    mPreviousState = state;
                }
            });
        }
    
        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {  
            if (mTouchTarget != null) {  
                boolean wasProcessed = mTouchTarget.onTouchEvent(ev);
    
                if (!wasProcessed) {  
                    mTouchTarget = null;  
                }
    
                return wasProcessed;  
            }
    
            return super.dispatchTouchEvent(ev);
        }
    
    }
    

    Now, we have a ViewPager that retains control of touch events once the page starts changing and releases it when paging is idle or settling.

  • Renaming files by pattern

    Occasionally (and especially when receiving assets) I have the need to rename multiple files at once -- often by some sort of pattern. For instance, I may need to rename all files with the string "_msg" in it where the file ends with ".png". Previously, I might have manually found and renamed all of them or written some hack of a bash "for loop" to iterate over a find result. Neither options are quick or easy.

    Recently, I found a great and simple util called rename to quickly and easily rename files with simple search-and-replace functionality.

    In this example, I'm renaming any .png file under a drawable folder, replacing _msg with _message.

    rename s/_msg/_message/ drawable*/*.png

    The rename util (not the same as mv) comes standard with most linux installations, but I'm on Mac OS X and that means I have to get it separately. In order to easily get rename, I use homebrew.

    1. Install homebrew. ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
    2. Install rename brew install rename
    3. Done.
  • How MeetMe Went International on Android

    Check out my post on how MeetMe went international on Android over on our Engineering Blog.

  • Joining Android Alliance Philadelphia

    I was recently asked by Corey Latislaw to join her, Chuck Greb, and Arpit Mathur in helping organize the Android Alliance Philadelphia group. I am proud to announce that I have accepted the position as Social Media Director of Android Alliance Philadelphia and that I plan on helping to create an even more engaging community. I am excited to help bring in even more Android enthusiasts, creators, and users with interesting topics and informative events.

  • Looking at Android Framework source quickly

    Even though I have recent checkouts of the Android source on my local machine, I usually prefer a more convenient and quick way to look at the platform code. Looking through source files on my local machine can often be slow to find the appropriate files and unreasonable to keep open in an IDE all of the time. Instead, I've been using the copy of the Android source that is hosted on github.

    Generally, if I'm looking for something like 'How is ListView implemented in Froyo?', I'll open up the source in github at https://github.com/android/platformframeworksbase, hit 'w' as the shortcut for switching branches and tags, type in 'froyo' and choose the right branch, hit 't' as the shortcut for finding a file in the repository, type 'ListView' and hit enter to open the file. Now I have the ListView implementation open in Github and ready to peruse!

    What's nice is that at myYearbook, we have a github:enterprise instance where we host our own internal code. So in the same way I can figure out how ListViews are implemented in Android, I can also figure out what our current Android versionCode is. Open the internal github to the myYearbook repository, hit 't', type in AndroidManifest.xml, and then use my browser's find functionality to look for 'versionCode'. Done.

    Awesome!

  • Lightning Talk: Drowning in Images

    Last night, I gave a lightning talk alongside Matt Smollinger (a myYearbook iOS developer) and other local developers for Philly Tech Week 2012. My talk centered around downloading, caching, and displaying images in an Android application. Check out Drowning in Images -- Memory Management or all of my presentations. You can also watch a video of my presentation on YouTube. I have to thank Android Alliance Philly and Philly Cocoaheads

  • parcelabler: for implementing Android's Parcelable interface

    [Update 2014-09-02]: Since this original post, a plugin has been made for Android Studio/IntelliJ by Michał Charmas with contributions from me as well. See android-parcelable-intellij-plugin for installation instructions.

    I have created a tool for making the methods needed for implementation of Android's Parcelable interface within a pre-existing class.

    1. Open the parcelabler tool.
    2. Copy the full code of the class into the "Code" text field.
      Example code:

       public class Photo {  
      
          /**  
      
           * Caption for the photo  
      
           */  
      
          public String caption;  
      
          public int commentCount;  
      
          public long photoId;  
      
          public boolean isDefault;  
      
          public Bundle metadata;  
      
          public CommentHandler commentHandler;  
      
      }
      
    3. Click "Build" to create the methods

    4. Copy the methods into your class

    5. Add implements Parcelable to your class definition

    Now you should hopefully have a working implementation of Parcelable in your class.

  • An adb (Android Debug Bridge) wrapper for installing from a URL, installing to all devices

    At myYearbook, we produce our internal and release candidate builds for all of our Android applications using Jenkins CI. This allows us to automatically produce builds when changes are pushed to code review (through gerrit) as well as when they’re merged upstream. This process is great for keeping integration clean and organized, but it means that QA, product development, and sometimes developers have to download the produced APK from jenkins on to their computer, and then install from the location they downloaded to. In order to expedite this process, I wrote a wrapper script for adb to allow the installation of an APK from a URL.

    To do this, simply change your usage from

    adb install /path/to/app.apk

    to use a URL

    adb install http://my.server.com/app.apk

    Additionally, use the -a flag to execute your commands on all devices.

    adb -a install http://my.server.com/app.apk

    Get the source: the adt-plus project on github!

  • Fixing constant splash screen on a Motorola Droid 2

    If your Motorola Droid 2 is in a state of constant loading (at the startup/splash screen) something has gone awry with your device. Unfortunately, the only way I know to resolve this is to perform a hard reset. This hard reset wipes the operating system of the device and reinstalls it from memory. You will lose your installed apps and have to re-download them. If you purchased apps, as long as you log in to the device with your same email address, you will be able to download the apps again for free.

    To perform a hard reset of the device,

    1. Completely turn off the device (remove the battery from the device).
    2. Put the battery back in
    3. Open the keyboard, and hold the X key and then hold the power button.
    4. The device should turn on with a triangle with an exclamation mark with an Andy (the green Android mascot)
    5. Click the Search icon on the keyboard (not the soft key on the screen)
    6. Use the volume buttons to navigate the menu. Volume up/Volume down for up and down respectively. Navigate to Wipe data/Factory reset.
    7. Click the Camera button (hard key on the side) to select this option.
    8. Tap the Menu soft key (on screen) for “OK” to clear the device.
    9. Once complete, navigate to “Reboot system” and click the Camera button again to accept.

    The device should now reboot and start up properly. You’ll have to re-activate the device and go through the standard set up process, but at least your device works now!

  • XSLTD: It's Alive!

    I've got the daemon running, accepting connections and commands. I've got a client together and running commands. It all works. More information to come....

  • XSLTD Alpha: Almost There

    The code is almost complete for the alpha version of XSLTD written in Scala. It's not the prettiest bit of code, but it's already accepting memcached protocol commands for XSL/XML storage and retrieval. I'm fighting with my HashMap right not to get the data in/out for those values, but it's coming along nicely. If I stick around again tonight and fight through it, I should have something ready to test and maybe even some stats up. Stay tuned...

  • Scala: Get character from character code

    Let's say that we are taking in a set of numeric ASCII codes from which we want to get the corresponding character.

    val charCode = 45  
    
    val character = charCode.toChar
    
    // Additionally, because of the way scala works, we could just do this, if it's a pre-determined value  
    
    val character = 45.toChar  
    
  • Update: Halloween Costume: Raptor Jesus

    Two nights ago, I posted about my costume, Raptor Jesus. Since then, I've painted the full head and gone to work with the costume. I used the female ends of zip ties for teeth, which ended up looking pretty good for the costume. I'm glad I thought of that.

    At work, I won funniest costume! With the prize ($100 gift card) I broke even on the cost of the costume. Pretty cool to be able to have fun for free. Pictures below.

  • An Excellent Python Cheat-sheet

    I was just browsing through Reddit and found this awesome cheat-sheet for Python. I've dabbled in Python in the past, and this will certainly be of use in the future. This cheat-sheet gives examples for the majority of basic language constructs.

  • Halloween Costume: Raptor Jesus

    I've been hard at work on my Halloween costume: Raptor Jesus. I'm going into this knowing that very few people will actually get my costume. At least for them, it will be fantastic.

    I started last night on the different parts that make up the head.

    Tonight, I pieced them together to make the full head. * BAM. It's put together: http://www.flickr.com/photos/55094601@N07/5116728772/ * And with more paper mache to cover the tape used and prep for painting (tomorrow): http://www.flickr.com/photos/55094601@N07/5116737114/

    Can't wait to paint this sucker tomorrow. Paint will be what makes or breaks this project. Wish me luck...

  • Embedded Electronics with Arduino

    I've recently been thinking about how I could get into embedded electronics and came across a cool open-source project called Arduino.

    Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

    That blurb pretty much sums it up. I've decided to commit some time and effort into this project, so I've set up a new desk and set of drawers in my bedroom specifically for breadboarding and Arduino programming. I've also purchased a kit and a book on Arduino from sparkfun.com.

subscribe via RSS