Monday, April 3, 2017

Publishing to a Nuget Server

First, the Nuget CLI needs to be installed on your machine. Place the .exe in a folder and add that folder to your local path. The nuget CLI exe can be found here: 

https://dist.nuget.org/

Run the following command one time to set the api key permanently for your nuget server. 

nuget setApiKey yourapikey -source http://yournugeturl

Change directories to where your .csproj file is located and run this command: 

nuget spec

The command above will generate a nuspec file. Edit the nuspec file and delete or fill in any elements without $. The $'s indicate variables that will be automatically replaced during the pack process. Do not change those elements. 

Next edit your assembly info for your project:

Edit /properties/AssemblyInfo.cs using Visual Studio

In the assembly info file you'll find all the properties for your project. I recommend that you let Visual Studio supply the build and revision numbers (so 1.0.*) as mentioned in the comments in this file. Make sure other values are set to your liking. 

Next, from a command prompt, run the following command:

nuget pack

This will package up your project and create a .nupkg file for upload to the nuget server. Now you're ready to push your package to the server. Run the following command and you're done: 

nuget push yourpack.nupkg -source http://yournugeturl

Thursday, September 17, 2015

Efficient CSS Using Child-Selectors

So, I'm working away on acaexpress.com and I find myself forgetting this over and over. I figured it would be a good idea to write a blog post about it to remind me there's a better way. 

Here's a typical use of CSS to assign margin to some images: 

<style>
    .issuerpics { margin: 15px; }
</style>

<div style="text-align:center">
    <img src="=logobluecross.png" alt="Blue Cross" class="issuerpics" />
    <img src="=logoaetna.png" alt="Aetna" class="issuerpics" />
    <img src="=logocoventry.png" alt="Coventry One" class="issuerpics" />
    <img src="=logocigna.png" alt="Cigna" class="issuerpics" />
    <img src="~=logouhone.png" alt="United Health One" class="issuerpics" />
</div>

Note that each image has a CSS class assigned to it. It's a logical technique, but not the most elegant one. Below, the parent element (div) is assigned a class and then the CSS is written to style the child elements of that class. It's less code, more readable, and in general more elegant. 

<style>
    .issuerpics img { margin: 15px; }
</style>

<div class="issuerpics" style="text-align:center">
    <img src="=logobluecross.png" alt="Blue Cross" />
    <img src="=logoaetna.png" alt="Aetna" />
    <img src="=logocoventry.png" alt="Coventry One" />
    <img src="=logocigna.png" alt="Cigna" />
    <img src="=logouhone.png" alt="United Health One" />
</div>

In general, it's best to make the code as readable as possible. Less code is usually better as long as it doesn't sacrifice readability. This change accomplishes both. 

Thursday, August 14, 2014

Lime ORM for Android

Hey friends. I wanted to let everyone know I've released a little library called Lime for Android. It's an ORM layer inspired by Microsoft's Entity Framework. I feel it has a few advantages over some of the other layers out there.

  • It's fast. Lime uses reflection to populate objects from cursors, but object inspection is done only once and cached. 
  • It's efficient. Lists of objects are backed by cursors so scrolling through huge data sets only requires conservative memory allocation. 
  • It's flexible. Most layers in Lime are exposed to make using as much or as little as necessary a simple matter of choice. 
  • It's familiar. Lime works with Android's content providers, observers, and loaders. It's all the things you already know, but easier. 
Stop by the Lime site on Bitbucket and take it for a spin. I think you'll dig it. 

Wednesday, July 9, 2014

Pull To Refresh on Android with SwipeRefreshLayout

In March of 2014, without much fanfare, Google added the SwipeRefreshLayout widget to the Android SDK. This addition formalizes the pull-to-refresh mechanism on Android. Let's take a look at how we'll use it.

First, make sure you have R19.1.0 or newer version of the Android Support Library in your project. R20 is the first version of the library to include the new layout. Once it's in your project, create a simple activity layout with the SwipeRefreshLayout at the top of the view hierarchy. While this isn't explicitly necessary, it makes sense that the entire activity be pulled down to refresh.

It is explicitly necessary that this layout have only one child. In this example, we'll make the only child a TextView for simplicity. Here's a look at our activity layout:

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent">

   <TextView android:id="@+id/text1" 
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content" 
   android:text="@string/hello_world" />

</android.support.v4.widget.SwipeRefreshLayout>


Now that we have the layout added, we'll need a little code to make the refresh happen. The new layout has a method to setOnRefreshListener. So let's take a look at our activity with that listener connected:

public class MainActivity extends Activity { 

   SwipeRefreshLayout layout; 
   TextView text1; 

   OnRefreshListener refreshListener = new OnRefreshListener() { 
      @Override public void onRefresh() { 
         text1.setText(new Date().toString()); 
         layout.setRefreshing(false); 
      } 
   }; 

   @Override protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
       layout = (SwipeRefreshLayout)findViewById(R.id.layout); 
       text1 = (TextView)findViewById(R.id.text1);
       layout.setOnRefreshListener(refreshListener);
       layout.setColorSchemeResources(color.holo_blue_dark, color.holo_blue_light,color.holo_orange_dark, color.holo_green_light); 
   } 
}


Notice that we need to call layout.setRefreshing(false) when our refresh code is finished. This method stops the animation and let's the layout know that our work is done. Typically this would be called when a loader in the activity completes. 

Also, take a look at SwipeRefreshLayout.setColorSchemeResources. This method allows you to choose 4 colors to be in the animated bar while the layout is refreshing. 

SwipeRefreshLayout is a great addition to the SDK and goes a long way to standardizing a user interaction method. Implementing will give your users comfort that their app is acting in a standard fashion and also save you space on the ActionBar where your refresh button previously would have been!

Thursday, August 9, 2012

Emulating the Nexus 7 Display Properties

Ahh the new Nexus 7 tablet is a sweet piece of hardware! On top of that, it's selling like mad. Are you on the waiting list, but need to make sure your apps are ready for it? This blog post is about creating an emulator image to emulate the display of the Nexus 7.

Before we start, please read the Android developer blog post on getting ready for Nexus 7. It's a good start to our discussion. Getting Your App Ready for Jelly Bean and Nexus 7.

Now that you're up to date, you know the new tablet is one of the first to sport the tvdpi screen density. If your app isn't ready for it, you might be in trouble. So, what do we need to do to set up an emulator for this density?

  1. Open AVD Manager and create a new virtual device named "nexus_7".
  2. Unless you have set up the hardware accelerated emulator set the "Target:" to Android 2.3.3. This will run fast enough to test your apps for the display. Note that you're not creating a real Nexus 7 emulator but this will be sufficient to test your app for the display! If you really want to test Jelly Bean, you'll want to set up the hardware acceleration for your emulator. Hopefully we'll discuss that in another blog post.
  3. Set up a sufficient SD card size. 
  4. Under "Skin:" choose resolution and specify the Nexus 7 resolution of 720 x 1280. Note that we put 720 first because we want the emulator to start up in portrait mode just like the device.
  5. Under "Hardware:", choose an Abstracted LCD density of 213. This is tvdpi!
Now you're set! When you start the emulator you will probably want to set the Launch Options to scale the display to 8 inches, especially if you're on a laptop screen. Now you should be able to test your layouts for the new Nexus 7. Have fun. 


Saturday, February 18, 2012

AT&T Mobile App Hackathon Dallas

I'll be attending the upcoming Hackathon this weekend representing the Dallas GTUG. Get signed up on Eventbrite! There are still a few spots left.

About the Event:
 Mobile App Hackathons is an event geared towards getting your app, business or idea venture to market! We will provide on-the-ground technical support, known as "senseis", from AT&T, Microsoft, Amazon, HTC and others to help you accelerate the execution of your ideas/business, rapidly kickstart a prototype mobile application and spin-off a successful venture.

Cost: FREE
Kickoff: Friday, February 17, 2012 6:00PM-8:00PM
Hackathon: Saturday, February 18, 2012 at 10:00AM-8:00PM
Sign Up: http://mobileappdfw2.eventbrite.com/

Monday, November 7, 2011

Startup Weekend Google Tech Bootcamp

I'm excited to annouce the upcoming SW / GTUG Bootcamp. There will be lots of good Android information and a code jam to get you ready for Startup Weekend. Here are the details:
Startup Weekend - Google Tech Bootcamp
Admission $5
Saturday November 12, 1:00pm - 5:00pm
ng Connect Gravity Centre
2900 West Plano Pkwy Plano, TX 75075
The following topics are on the agenda with more to come soon:
  • Android Cookbook - Scraps and Ideas for Startup Weekend 
  • Getting Started with App Engine
Keep an eye on this page for updates!