Further Posting Cancelled

Until Monday, due to the intervention of my stag party.

I'll get back to work (assuming I come home safely!) on Monday, see y'all then.


Android Theory

I've been delving around in Android and Java help materials - tutorials, guides and forums - to help me put together this part of the app.

So, here's the first thing that I've found out, from the official guide to developing for Android here:

An activity represents a single screen with a user interface.
That means I don't want WeddingLogisticsActivity to be a big thing - I want to deal with something called, I don't know, SplashScreenActivity (now referred to as SSA) which is aimed purely at this initial screen of the app.
[Note for future reference - I will probably want a test so that SSA only runs the first time you open the app. Easiest thing that occurs to me is to check whether the variable WeddingDate is empty; if it is, run SSA, otherwise don't. That should avoid problems.]

Looking in more detail at this page, I think the way to proceed is to tell WLA to start an activity called SSA, in the terms
Intent intent = new Intent(this, SignInActivity.class);
Or in my case:
        Intent intent = new Intent(this, SplashScreenActivity.class); 
Then I set up the beginnings of the new Activity for SSA in the same way; only to realise that I need to put SSA in its own file, called (logically enough) SplashScreenActivity.java as otherwise the app would get confused.
Now, I'm still seeing an error in WLA on the line Intent intent etc, as the app doesn't seem to recognise it; so I tried adding an import statement as below:
import android.content.Intent;
which solved the problem.
Import statements are my friend.

Right, in the classic way of things, it is past time to post this, and I still haven't solved the original problem. Tomorrow, I promise!


Java Adventures

So, this is where I've hit the problem that Java is not a language I'm familiar with.

So that's why this post is a bit late - I've had to delve into some Java resources to figure out how to distinguish my arse from my elbow.

Anyway, I already had:

public class WeddingLogisticsActivity extends Activity {

/** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

I'm fairly sure I need to declare a DatePicker (tell the app to expect a DatePicker, and what to call it), so I added
DatePicker WeddingDate;
This means when I refer to WeddingDate, the app knows what I'm talking about.
Then, from looking at example code, (mostly from hackaday which I mentioned before), I need to tell the app what to do with WeddingDate. And...I can't quite figure that bit out yet. More reading required!


Code: Import, Activity, Extend

This next bit is focussed in the source-code folder (src), in a section named WeddingLogisticActivity.java

Eclipse has automatically added in what you see on the left here.
First of all we have the name of the package, which will eventually uniquely identify Wedding Logistics on Google Play.
Then we have the import statements. One analogy for these is academic references - if you write an essay which doesn't show the sources for your statements of fact then your readers will think you're making it up. Well, think of your app as a very sceptical reader - unless every statement is ultimately backed up in a reference [unless every method is in an imported library], it won't believe you [won't be able to execute that method].

The import statements I have already just cover me for the basic operation of the Android Operating System, and for the initial Activity that I'll get to in a moment, so I'll be adding a few, to deal with the Context (the situation on your Android), the View (what's on screen), an OnClickListener (to notice when, say, the user clicks on a button), deal with Buttons, Toast (messages that appear temporarily on screen. So called because they pop-up, I think), and a DatePicker, &c.
I've got the outline of my list from the excellent hackaday.com Android Tutorial and then added one for the DatePicker. Eclipse helpfully highlights all of the import statements I'm not using at the moment
(see the little row of symbols on the left?) so I can remove any unnecessary imports once the code is finished. Equally, as I expand the app, I'm likely to need to add more imports to cover new features.

Then we declare a public class called WeddingLogisticsActivity (henceforth abbreviated to WLA), and that it extends the core Activity.
Just to unpack that a bit - public means that other processes can refer to WLA; class - well, for a full definition of that I'll give you the wikipedia article, but the short version is that it means I could have several examples of WLA, based on the definition of it given here.
As to the bit about extending Activity, well, the Activity is a core Android class which handles some basic stuff for me - saying WLA extends Activity is a way of telling the system I want WLA to start with all the attributes of Activity, and then I want to give it some more.

At present, all WLA does which is apparent to the user is load the screen from last time; however, if the user attempts to enter the date, nothing will happen. If they click Done, nothing will happen. Unfortunately, I'm out of time, so I'll get to rectifying that next time!


Projecting in Eclipse

Starting with Eclipse, we have to start a new project, which is pretty simple:
File > New > Android Project.
I am calling this project Wedding Logistics, though in places where I feel the need to abbreviate that will be WedLog.

Then I have a decision to make; there are various versions of the Android Operating System out there in the wild. The earlier the version I opt for, the more phones will be able to successfully run my app - but the fewer features I'll be able to use.
This calls for a little research; a quick google gets me this graph from Wikipedia.
The figures are a year out of date, and show 90% of users on Android 2.2 and above. Given that new Android phones are on Ice Cream Sandwich (4.0 and up), working in Android 2.2 is ample.
Now, for Eclipse purposes, we need to translate that version number into an Application Programming Interface (API) number. Android 2.2, aka Froyo, is API 8. This means anyone trying to operate my app on APIs 1-7 is out of luck, but I should be okay for 8 and up.

Next thing I have to do is name the package; this is something for when [eventually] I get this thing onto the App store. Every app needs a unique package name, and to guarantee that, the convention is to use your website url followed by the app name. So for me, that is uk.co.blogger.becomingandroid.weddinglogistics for this app. Ungainly, but it'll do.

Now Eclipse will do its magic - it has created a raft of files that I will need as part of the app, and populated them with bits of generic code. This is part of where an IDE saves hassle. Now, as I mentioned last time, the output from Droid Draw can come straight into Eclipse - specifically, under the folder res (for Resources), layout, main.xml
Now here, I'm following the advice from a tutorial I used; I may need to alter it later, but it will do for now.
I go and have a look at the results in Eclipse, and...ah. Oh dear.
There are two errors; and it doesn't look like it did in Droid Draw. I think the problem is that I used an Absolute Layout - it looked neater. I'll try it with a Relative Layout, remembering that this is meant to be fast-and-dirty!

 Now, calendar appearance aside, that's a bit more like it. Also, there not being any major errors, I can go ahead.
There are however some warnings, highlighting possible problems. On this occasion, they're reminding me that I don't need to hard-code the text (like "Welcome to Wedding Logistics 0.1") - it can go in strings instead. I'm going to ignore that this time, because this text is only appearing on this screen, so I don't see any real advantage to putting it in strings for easy re-use.

You'll also notice that I got rid of the second option for entering the date - firstly, this date-selector looks more like what I had in mind for that, and secondly I have changed the note at the end. This will make the code simpler, though I may return to giving users an approximate option on the front screen later.

So, with the extra faff I had to go through with this, I'll be coming back to the actual code in the src folder next time. There will be import statements!


Making a start

First, a quick reminder of what I decided last time were the core features to aim for:
So some form of calendar function - allowing you to set your date, then keeping track of a countdown; then an ability to enter notes with target completion dates; ability to check back previously created notes; and probably a display with the next few tasks.
Now, there are a variety of ways to approach the next stage. One would be to fire up Droid Draw and plot out the user interface first, then once I'd plotted out how I wanted the thing to look I could work on pulling the back-end together to make it work. Another thing I could do would be to plot out the logical flow of data - where the user enters it, how the app needs to manipulate it, and how it needs to be output.
The third focus which occurs to me is to think in modules of code - a module for note-entering, a module for checking previous notes, a module for displaying priority tasks, a module for the count-down.

Thinking further, however, I realised that working in Droid Draw and with modules of code may be compatible with each other; after all, when you press a button, you want it to do something; so it has to be associated with a bit of code to tell the app "When 'Go!' is pressed, this is what you do," or whatever. Based on the fact that I can combine these two approaches, I think that's the way to go - the disadvantage of working with dataflow is it's less concrete, and so for a (relatively) simple initial app it's probably unnecessary.
My only wariness around starting in Droid Draw is concern I might get too bogged down in making it look pretty before it actually works; then again, I should be able to replace an ugly button in a stupid place with a shiny one placed ergonomically or whatever without actually changing the underlying code. So, as long as you can see all the features on the screen, no complaining if it's ugly!

So we fire up Droid Draw, and it looks something like this:

As you can see, we've got an Android screen on the left, options of things to add top right, and bottom right is currently a blank space.
[The blank space is where the output xml will appear when I hit 'Generate'. The xml will basically be code telling Eclipse how to make the screen look like what I draw on the left. I'll go into that process in more detail later.]

 To me, the obvious place to start is where the user will commence, first time they open the app - the calendar to pick a date.

What you see here is a first stab at that. The explanatory text is done using TextView boxes; a DatePicker gives us our calendar, and at this stage I'm unsure whether the 'Done!' button for that is necessary

I have then put an alternative, for anyone using the software before they have a date booked. This is just using text boxes at the moment; ideally I'd prefer a drop-down list with months, and then the same with years; or I could settle for radio-buttons with Spring/Summer/Autumn/Winter and then a box for years. Something like that, I'm flexible at this stage.

Items are named, so for example the calendar is called @+id/date_picker, the Done button next to it is called @+id/exact to distinguish it from the other Done button being @+id/approx, and so on. You get the idea - everything has a name which is short and to the point, so that when I'm writing code about it I can see what I'm doing more easily.
Once I'm done with this (for now), I hit 'Generate' on Droid Draw, which spits out a load of lovely xml [for anyone interested, that can be found here]. I can paste that directly into res.layout/main.xml [all will be explained!] and have the above appear in my app. Next step is the code.

Oh, one last point - see my little p.s. note to the User at the bottom? Yeah, it isn't just good to remind yourself what's going on by commenting your code - let the User know too!

Next time: Into Eclipse


Beginnings 3: Early Design Decisions

So, I'm set up with all the tools to write an Android app, give it a pretty interface, and test it. So this seems to open the question - what do I want it to do?

There are thousands of apps already available, to do almost anything imaginable. You can get an app to play The Sims. You can replace your touchscreen keyboard. You can add an archery scoring tool.
According to the might wiki, there are 450,000 apps for Android! How can I do something that's never been done before?
Well, bluntly, I can't. I may not even be able to do something better than it's been done before. That's okay though - it means rather than searching Google Play with ever odder search terms to find something that hasn't been done before, I can just come up with something that seems achievable and get cracking.

I've been spending a lot of time lately helping my fiancĂ©e in planning our wedding (for anyone interested in that side of things, her blog as linked there is a good place to start) and the number of lists and pieces of paper to keep track of everything is insane!
Everything has a different timescale; different participants; costs to budget for; and so on.
Basically it is one of the largest events that people are likely to find themselves organising in a non-professional context. Maybe I can do something to help?

Thinking about this, I can think of a lot of things that an 'ideal' version of wedding planning software would do for you. The key thing is to start with a core functionality that's actually useful and then add capabilities once the core is up and running - otherwise it becomes a huge project for one person, I have to learn a lot more before I can get started, and I'm more likely to give up with it incomplete!

Ideal Version:
Keep track of budget - how much things cost and what proportion is paid for.
Keep track of RSVPs - to the main event/reception (if separate), hen and stag.
Replace all the little bitty notes - to-do lists, records, contact details, ideas.
Count-down - knowing what day is W-Day, and being able to categorise tasks by 12 months before, 6 months before, the day before, day of the wedding, whatever.
Tracking primary responsibility for tasks - is the groom handling the music? Is the bride mostly dealing with the caterers?
Be able to synchronise between multiple devices - the bride and groom, and possibly also the best man, maid of honour, ushers, even parents.
With the above, ideally be able to output something (be it a spreadsheet, Google Doc, whatever) to a computer for handling on a larger screen.
BACK UP AUTOMATICALLY - this is a big deal. The more of the critical pieces of paper that are moving onto an Android, the more careful we need to be that one inopportune crash, or getting your phone nicked, won't mess everything up; and relying on busy people to manually backup is going to lead to some failures. I have no idea how easy this is - have to look into it later.

That's quite a lot of features, and different pages within the app, all of which would have to interact smoothly with one another. What's the core of it? I reckon the combination of a to-do list and count-down will do the trick - key reasons being I think it's enough to be useful, but it doesn't require interacting with other phones or linking to PC; it will have easy room for expansion in noting responsibility for tasks; and phones are obviously *already* good for noting contact details, so integrating those into the app aren't the highest priority.

So some form of calendar function - allowing you to set your date, then keeping track of a countdown; then an ability to enter notes with target completion dates; ability to check back previously created notes; and probably a display with the next few tasks. That sounds like a pretty good initial feature list to me.

I can start breaking that down into what I'll actually need code-module-wise next time. Then I can give myself a specification - to write code able to perform these functions - and then I can maybe start writing some actual code!


Beginnings 2: Software and Tools

So now we know why I'm doing this, let's have a look at what I'm using to do it!

First off for any programming, it's good to have a solid Integrated Development Environment, or IDE. It is possible to write code using Notepad and then compile it with a standalone compiler, but that's like saying it's possible to write a novel without having proofreaders - you're making your life more difficult, and at the end of the day the results will be worse.

To compare code in an IDE with the same code hand-typed:

So here we have a Java "Hello World!" program.
You can see that there is colour-coding for common elements - the declarations are purple, comments are in green, and the string "Hello world!" is blue.

What you can't see is that Eclipse has automatically indented lines as they are typed; nor that when you open a brace { or parenthesis ( it closes them.

It will even, when you type System. show a list of possible continuations.

Then if you, say, forget the semi-colon to end a line, it will highlight that line as problematic and suggest you add it.
And here is the equivalent hand-typed.

There's no indentation, so it's harder to see what is going on; and with all the text the same colour doesn't help.

If I forget a piece of syntax, or misspell a command here, the first I know of it will be when the compiler throws an error. Not fun.

So, an IDE is essential - but which one to use?

I have chosen Eclipse. Primarily, this is because Eclipse is a very popular IDE for the Java family of languages - and Androids run on a form of Java. It is also because Eclipse is free (yay! says my wallet) and open source (yay! say my principles).
Eclipse can be found here.
Once you've installed Eclipse, you need to add the right attachments to make it work with Androids. It's like buying an electric drill - you need the right drill bit to do the job.
Specifically, you need the Android Development Tools (ADT), and the Android Software Development Kit (SDK). Fortunately, there's a very good tutorial on the whole process here to walk you through that.

Once you've done this, Eclipse doesn't just have the usual advantages of an IDE - you can also run virtual Android devices with a variety of specifications, to test your program on more phones than just the one in your pocket! (More testing is always good...)

So far so good. I've added two more bits'n'bobs which look as though they may be useful, and offer functionality which is lacking in Eclipse:
DroidDraw, which is a visual environment for laying out interfaces and screens. Hopefully when it comes to prettying up an app, this will make the process reasonably simple. DroidDraw is found at this site, which not only has the downloads, but also tutorials on how to get started with it.
SQLiteBrowser, which is a database manager, found (among other places) here. I've added this because it may help with handling storage and retrieval of data.

Last thing to mention:
Scrap paper and a pencil/whiteboard and a pen can also come in handy; especially for planning out the outline of a program before you jump in and start coding.

Next Steps: So what do we want an app for?


Beginnings 1: Whys and Wherefores

Who am I, and why am I doing this?

I'm young, highly qualified and unemployed. There's a lot of it about, oddly enough. I want to get a job developing software, and part of the problem is that my formal programming education is slim; so I need pieces of work to point to, an "I did that!" I am learning to write Android apps partly just to improve my skills, and partly to build up a portfolio of work which I can show to prospective employers.

Why blog about it? Self-discipline, primarily. If I know that the results are public, I have more motivation to push on through the debug phases, the design crises, etc. With the added possibility of showing the blog itself to people.

Why Android, not iOS?
1) I have an Android phone, and it's much more appealing to write an app I can use myself.
2) I have an Android phone, so I have a test-bed in my pocket.
3) Getting an app out on the Android Market (or Google Play, as it seems to be now) is a lot easier than getting one onto the Apple Store.
4) I just prefer the Android philosophy of an open platform.

Coming soon: Software and Tools.