26 November 2011

Working on gui for adding and deleting from the database.

I've been working all day today on a method of adding to the database. I had my dialog set up before which set the content view to a static XML layout. When it came to implementing a way of storing the information from this layout I ran in to trouble. I was setting up a listener for an "add" button within the dialog and this had an onClickListener anonymous inner class implementation. This would fetch all of the data from the input forms and add it to the database, however there was an issue with the resources it could access which was causing a NullPointerException when trying to inflate the button from the layout. There seemed to be some issue with loading the Button in with the findViewById() method which had something to do with the access level from within the inner-class to the outer-class's super-class and the fact that it used a common interface which was being overridden from with in the inner-class (A mouth-full, I know!).

I then switched my approach and used an AlertDialog instead. This worked out to be a much better solution because I was able to manually inflate the XML layout and add it as a single view to the AlertDialog builder. Then when it came to implementing another listener for the setPositiveButton method of the builder, I could just open a new database connection using the database adapter and add the transaction that way. It's a much cleaner solution that doesn't involve trying to figure out all of the inheritance and access issues.

I used the same approach for deleting transactions, however the AlertDialog builder has some pretty cool methods for building check-box lists for a dialog, and now I'm just working on a solution for deleting the selected items from the database.

Next thing I've got to do is add a method for deleting a list of transactions from the database in the database adapter class, and pass the list of selected transactions through for deleting from the above list. Some error checking to ensure the forms don't contain an empty string will also need to be put in place because I'd imagine that could generate a NullPointerException, however I haven't fully tested the input sanitisation yet.

I also would like to review how I'm going to display the list of transactions, because viewing by date doesn't look that good. I'm thinking now that maybe I should just add a tick box to each row in the table and if it's selected the user can bring up the menu and delete them that way instead as well as perform other tasks. I'll think about that some more at a later point.

23 November 2011

Menus and dialogs

So, now that I have my transaction database set up, it's time to add the functionality for adding transactions to the database. The way I envisage doing this is by adding a menu that the user can select an icon to add or delete a transaction. The menu option the user selects will pop up a dialog that the user can then enter in the details of the transaction they wish to add. For deleting a transaction the user can maybe then enter the id of the transaction or else select from a list of transactions they wish to delete. Upon pressing the back or enter button, the fuel tab should then be refreshed to update the transaction list.

So far tonight, I've manage to get the menu implemented, and a number of methods that pop up a dialog when a menu item is selected. There are currently place holder assets for the menu icons which need to be changed. Now it's just a matter of designing the input dialog layout and sanitising the input, and adding the sanitised input to the database. I'll probably get the input dialog designed by the time I'm done tonight, but I think I'll leave the sanitisation for another day because it's a much bigger job that requires me to be completely focused. I'm making good progress.

In other news, I was able to sign up for internet banking today which means that my google wallet account has been verified which means I can start charging money for apps. I'm not planning on charging for anything quite at the minute, but based on how much of an app I've got by the deadline I've set myself and how much functionality I can provide a user with beyond that I might decide to place a charge on a premium version of my Driver Tools app as I had originally stated in the concept blog post. Nothing has been decided yet however and it will be initially be released for free regardless.

22 November 2011

Current problems with number cruncher implementation

I'm laying out a number of bugs and design flaws that I've noticed so far that will need to be addressed, listed in order of importance.

  1. Menu input inconsistent with looping indexes for pulling data, and needs a complete overhaul.
  2. Values of number of options for each prediction needs to be dependent and consistent with the total number of options and predictions. The sum of all of the options per prediction should equal the total number of options.
  3. There is currently no method for retrieving a list of users who have selected the correct options.
  4. Some of the user names which are not plain text still have formatting tags surrounding them such as italics tags and bold tags.

I'll try and get a flow chart for the process of identifying the winners and then adding the points subtotals and I'll post it either tonight or tomorrow night.

19 November 2011

Database amendments and custom adapter debugging

This morning, I have made a number of amendments a couple of the classes which include the adding of a method for setting the date to the Transaction class. Currently the constructor for the Transaction class sets the '_transactionDate' field to the current date which means that the new setDate method is useful for if I simply want to use the Transaction class for storing information about a transaction that has been pulled from the database. This helped me fix a bug where the date was not displaying correctly in the graph in the stats tab. I have also added a "getDisplayDate()" method which returns the date of that transaction object as a formatted string which is a conversion of the "_transactionDate" field which is an epoch.

I have also added a method to the to the database adapter class which returns a linked list of transactions from the database which makes it easier for adding data to the user interface, as before I had a method that returned a cursor which contained all of the information from the database that was queried. Other small changes include an updated graph which uses actual information from the database. It currently looks like the following.




As you can see some changes need to be made to the visuals, however most of that are very minor changes and the core bones of the app is in place for more functionality to be added. Next on the list will be a for a user to be able to scroll up and down the table of transactions and a menu for the fuel tab that will add a new activity to the stack for a user to enter in a new fuel transaction. Last on the list is the sorting out the user interface, but I do want to get that done before I move on to something else. I don't want to let all of the work in debugging the user interface stack up on me because it will slow things right down.

As for the deadline I have set myself, I think I'm making good progress to be done in time for the date I set myself. Even though I only really have time on the weekends, last week I tried to do a small bit of coding when I got home from work and I managed that. Hopefully I'll be able to increase the amount of time I spend coding more and more over the upcoming weeks.

17 November 2011

Driver Tools update!

I've been working on the Driver Tools app for the previous 4 hours and I've made some amendments to the way in which data is stored. There is now a Transaction class for storing information about a transaction through out the life of the app. There is a method in the database adapter for storing a transaction object in the transaction table. I also have a dynamic table display now for the transaction display in the fuel tab. I've changed the fuel transaction database table to now include the date which is an epoch. This will be handier for adding time as a domain on a graph when it comes to that.

The next thing that needs doing is minor tweaks to the user interface, and maybe the set up of a xml style resource for making future changes to the way in which data is displayed in the app. I'm also going to write a method in the stats class for pulling the data from the database in to a list of transaction objects, at which point I can make other lists of data for setting up the graphs. There are also a few bugs which result in crashes when I pull data from certain columns in the database which I have to look in to so I'll try stay on top of things this weekend.

Cruncher implementation.

I've been working on the cruncher implementation for an hour or two each day this week and the progress so far is that I have the poll results page being parsed and each voter is stored in a hash-map where the key is the option they voted for and the pair is the user. The program accepts the url for the poll from the command line and for now the user is then prompted with a number of inputs for information about what each of the poll options mean. I think this will change in the future, and once I've debugged and tested this version of the application, I'll think about implementing some kind of dynamic GUI using java swing. Thought I'd post an update since I haven't yet mentioned anything about the implementation of this project. For now though, I'm going to start working back on the driver tools app, so a progress report can be expected later tonight or tomorrow.

13 November 2011

F1 Competition cruncher

Due to the fact that I made quite a bit of progress with yesterday and this morning's back end implementation, I have decided to Start a small side project that I want to get going while I'm working on the Driver Tracker app. This might turn in to larger project at a later point if I can get some more developers who want to get involved.

On the boards.ie motorsport forum they run competitions where by the put up a multiple choice poll with predictions about an upcoming race. Each prediction will have a number of points associated with it depending on how likely it will be as an outcome. The points are added up for each person who takes part in the competition and they are added to that posters total in a google docs spreadsheet. Due to the large number of people participating in this competition the results collection can be quite a bit tedious and I have offered my services to build a tool to automate this process.

I plan to build a tool for crunching these results and outputting the results to some kind of readable file. The program will be run from the command line and will accept a URL of the poll results as a parameter, as seen here. The next parameter should be the number of predictions, and the following parameters should be the number of poll options for each prediction group. For example, if we had a poll where there were 4 predictions and the first prediction had 4 possible outcomes, the second had 2 possible out comes, the third also had 2 possible outcomes and the last option had 3 possible outcomes, the correct use of the tool should then look something like "java F1NumberCruncher http://www.boards.ie/vbulletin/poll.php?do=showresults&pollid=20560 4 5 2 2 3".

I don't know how many other people might want to get involved, but once I have a beta version of this ill distribute it among the people who are in charge of updating the competition results and see if I can get another developer to try and do up a GUI for this or maybe work on exporting the data to a google docs exel format of some kind.

Simple transaction database implementation

After a bit of messing about with android database tutorials and mocking up simple ERDs with the mySQL workbench tool, I've managed to come up with a basic database design model. I'll be starting off with one table and implementing the features of the database as I implement each iteration of functionality in to the app. I'll be starting with the fuel transaction side of things, which means I've set up a fuel transaction table. So far the columns that exist are transaction id, user id, price, mileage, volume, fuel type and comments. The primary key is the Transaction ID, and the user id which is not being used at the minute, will be a foreign key.

Other Tables that will be included will be a car manufacturer table, a car model table and a user table. It's current state is quite simplistic in it's design but it will grow in complexity over time.

As for the implementation of this database, so far today I've managed to implement a database helper class, which deals with creating the tables if they don't already exist and updating the database if changes are made to the structure of it. I also implemented a database adapter class for dealing with raw sql queries for adding, editing and modifying entries; opening and closing the database; and also for fetching from the database. I now just have to work on the GUI for displaying the results of the database in a pretty way, and also for giving the user an intuitive way of entering in transactions and making it fit in to the GUI in a way that looks good. I also need to add a date column that stores the time of the transaction in the database.

11 November 2011

First week in new job!

Last Monday I started a new job with Realex Payments as an Integration and Support Analyst. It has been an exciting week becoming familiar with my new role in the company, but unfortunately I hadn't had much time to work on my android projects lately. My weekday consists of an early start out in Monkstown which involves an hour of sitting in traffic every morning. After work after about another hour of sitting in traffic I battle falling asleep on the couch at home, so I'm usually too tired to work on projects in the evening. I do however have weekends off which is new to me, because of my previous job. I plan to make full use of this perk and get some solid development time in on the weekends that I now have off.

This weekend I'm planning on getting the back end of the app set up with a few classes for storing information about different things. I'll do a bit of reading tonight so that I'll be ready to get stuck in tomorrow and hopefully I'll have something worth adding to the project by tomorrow night.

Also, a quick stats update for the lotto checker app. I'm currently at 1859 installs and 1461 active installs. This is a 78.59% success rate with users, and my impression would be that a lot of UK users probably download my app due to the fact that it is featured in the top 30 in the productivity section of the android market with out realising that it is targeted at Irish users for Irish lotto results. I'll have a look at the UK lotto website and see if that may be something to incorporate in to the next iteration of that project.

6 November 2011

Database design and android plot library.

Today I downloaded the latest stable release of android plot with the intent of learning how to set up simple graphs with static data and displaying them in a tabbed frame with in an android app. The API is fairly straight forward and there are a few tutorials on their wiki page with code snippets of the correct usage of the package. Using the samples from the wiki and what I have done so far, I added a simple X,Y graph showing fuel economy over time to the stats tab. For now the values are hard coded as the exercise was for the purpose of visualising what the graph looks like, and also for familiarising myself with the API should I chose to use it. It certainly looks well despite the fact that I haven't really messed about with the formatting of the default graphs.

When dealing with dates and adding them to a domain, they are put in an array as epochs which is the number of miliseconds since the date January 1, 1970. This will make storing dates easier in a database, but some method of converting string formatted dates to epochs will need to be investigated. I don't currently know if there is a method of doing it in any of the standard java classes.

The next thing I'll be working on is designing the database for storing information about transactions which can be adapted at a later point to store information about the individual models and makes of cars and their respective stats. So far the variables that will need to be stored as part of one fuel transaction are the total cost of the transaction, the current mileage on the odometer, how many liters were paid for and the date of the transaction. On the fuel tab I plan to have a list of all previous transactions which can be cleared if the user wants, or specific individual entries can be deleted from the database if they were entered incorrectly. I need to come up with a table design for the database that will allow me to expand on it in future when it comes to implementing other features of the app. Also I need to think about what kind of information I need to store about the users for the purpose of identifying the user or having multiple accounts or whether it is even needed.

4 November 2011

Tire information

The first thing I'm going to start working on is the tire information tool. The things I would like the tool to be able to do is educate a user about grip levels for braking, handling and acceleration; calculate the optimal tire pressure based on the weight and tire information; display data about the tire including information about the tires load, maximum velocity and some form of tool for compensating for increased speed indication due to a larger than standard rim size.

A lot of information about tire codes and general information about good tire practice can be found here. There are a number of other websites that will be useful for getting ideas about graphing grip thresholds and other important information that will be presented to the user.

Tabs

Using the tutorial I linked earlier on the Android developer references website, I've managed to code up the tabs and I have some make shift icons in the tabs place. This will be my starting point for developing this app now, and I'm looking at examples of sqlite and how to connect to a database in Android.

I'm now having a look at various different widgets for graph drawing and this one looks pretty straight forward.

Driver Tools

I've decided to get back in action developing apps with a brand new app. The reason I'm starting on a new app while I'm still testing and publishing updates for my last app is because I'm starting a new job on Monday which involves driving across town quite a distance every morning and then back again in the evening. I want to develop a driver tools app which will log fuel economy over time and it will contain a bunch of other tools for a driver to be able to adapt their driving style for a more economic drive. I feel this tool will be useful to me in the upcoming weeks as I drive to work.

Some of the things I would like the app to feature are graphing of fuel economy over time, tire pressure calculators and wheel size stats, route tracker which compares different routes on fuel economy and individual car profiles. This will mean that I'll be using APIs such as the GPS API and the databases API which is a side to android I have not yet used.

I've got an idea for the user interface design. I'm going to tab each of the functionality activities in tabs which I'm using this tutorial for. The methodology I'm going to approach this project with will be heavily orientated around good user interface design, robustness and security. I am also going to create two versions of this app, one of which will be free with ads the other will contain a bit more functionality and will not contain ads. I'll divided up the functionality and decide on how much I'll release for free once I've I'm in beta testing and I think I might release a beta on the market and update it until it is at an acceptable level of functionality to release a premium version.

In other news, my lotto checker app surpassed 1280 installs with just over 1000 active users today.