Social app update

Well, I finally got my search and my sorting figured out in the Firebase data. So, not I can show the latest info and allow searching that info as well.

My other concern is that the OpenFB doesn’t seem to be working on devices, only in the simulator as well as on the PhoneGap dev app, which I believe uses the local address which is why it could be working. My best guess at this point is that its an issue with the Auth Urls on the Facebook site, but as the buttons don’t seem to respond at all it certainly could be something in the code. As I am using Firebase anyway I will be looking at the Facebook integration there as well…

Ionic, Angular and Firebase

I have been looking for a backend for my app development and have come to the conclusion that Firebase is going to be the best choice for cost and features.

I have implemented Firebase in a social media style app I am doing and it is working very well using angularFire samples. I had a bit of an issue working with the database in separate views of the app but I think I have that figured out now. I actually had to ref the firebase database in each controller. Not sure if this is the best way to do it, but its working well.

I am using the OpenFB js to implement the sharing features, it seems to be working very well on my test device. I will probably touch more on OpenFB in a future post as it seems pretty easy to use and I think a lot of people would like to learn more about it.

Stay tuned for when I announce the app!

Ionic and AngularJS Timer App

As I work on several projects I figured maybe a timer app that I could add new projects, put in a time and have it alert me when its over. So I started with the very good sample code here: http://goo.gl/DJR0En from siddii and was easily able to adapt the array of jobs to include a bit of editing as well as adding a stop and remove button. I bumped up the interface a bit using Ionic Cards. But, I feel the interface could be better. Maybe swipe cards for each timer, a little animation etc.  Not too bad for the few hours I put in to learn Ionic and AngularJS.

The video of the app in action can be seen here: http://youtu.be/8KX8pa-dtZs

Ionic – Facebook and Pull-to-Refresh

Ok, added two new features to the demo app. I implemented a Facebook login and sharing using the OpenFB library.

https://github.com/ccoenraets/OpenFB

I also added a Pull to Refresh feature for one of the pages using the sample from Ionic

Actually the implementation was very easy, but since I still haven’t figured out what I am using for the back end its all show right now. But I am thinking it will be pretty easy to add my data refresher to the that function.

More Ionic

So, playing around with Ionic a bit more I decided to pull the initial data from the server and then store that onto the device using local storage, a technique I have used a lot in the past. It worked well except for a problem when using the ng-repeat. It seems that angular adds a hash key to the array to keep track of them The problem was when reading this back from local storage it had a repeating key, which broke the repeater. After much searching on removing these to no avail I finally found out how to stop it. In the hg-repeat you have to add a ‘track by ‘ that angular can use to keep track of the repeater. This allowed it to stop adding the hash key and breaking the app.

You can see the current result here: http://cincyplanet.com/ionic

It loads the first time from the server. Then saves that to local storage. This allows you to add new friends and save them on the device. Currently you cannot delete a friend. This is due to using the Ionic template set us to read the id number that has to correspond to the array position. I plan to change this to allow deleting of the friends, just not sure the best way to do it as of this writing.

Styling the Map

Now that I have the start page where I want it, let’s look at the map. Google maps actually have a style wizard you can use to get your map looking just the way you want it.

http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html

and the documentation on the styling: https://developers.google.com/maps/documentation/javascript/styling

Since I’m using a lot of red I decided to go with a slight red tinted map to give it more of a fun, cartoonish look to it.
Here is the resulting game screen
wpid-2014-07-19_10-23-50-2014-07-19-10-19.jpeg

The code was pretty easy to implement. For this example I will keep it more basic.
I already have my initialize function with my map that I just got from their sample page. So I only needed to add the JSON code from the wizard into a variable:
var styles = [
{
“featureType”: “poi.government”,
“elementType”: “geometry.stroke”,
“stylers”: [
{ “visibility”: “on” },
{ “weight”: 3.3 },
{ “saturation”: -41 },
{ “color”: “#ff7a80” }
]
}
]

I then need to create a new styled map

var styledMap = new google.maps.StyledMapType(styles,
{name:
“Styled Map”});

After that I have my basic map code with my map properties from their sample page. It’s after this that I can apply my map style to our now generated map:
map.mapTypes.set(‘map_style’, styledMap);
map.setMapTypeId(‘map_style’);

Notice I used my map variable. I’m sure there probably another way (a better way?) to do this, but this seems to work out pretty well for this game.

The screen above doesn’t show it, but I will be adding a back button as well to get back to the main screen.

Unhappy with the default game look

I have decided that I am not very happy with how the game is looking using the plain phone gap, so I am trying something new. Looking at Ratchet and Topcoat I have decided to go with Topcoat (http://topcoat.io).
I’ll be honest, Topcoat was not my first choice, it was actually Ratchet. But, after a few minutes of testing it seems either my system or the MyEclipse IDE does not like the Ratchet components. It would freeze up and not display correctly (the IDE, not the components). The Topcoat seems to play nice and has a good look to it. So, after downloading it I added it to the folder in the IDE. It seems a bit easier to use that Ratchet at first try as well. I added the code to the top of the page and after grabbing some code from their demo page was able to quickly change the look of the game screen:
wpid-2014-07-18_13-28-28-2014-07-18-11-08.jpeg

The title bar is the default navigation bar from the demo, the button is the mobile call to action button with my added default graphic and a Start Game text. I also placed the button inside a div tag to get it centered, I think it works out pretty well.

Here is the button code I used:

<div style=”text-align: center;”>
<button class=“topcoat-button–cta” onclick=“javascript:getUsername();”>Start Game<br> <img src=“icon.png” ></img></button>
</div>

You can see the call to my getUsername function I added the other day. As I am pretty happy with the intro screen I will move on to the game screen and try to get that looking a bit better.

Quote

Getting the Username

I decided to personalize the game a bit by getting the user’s name at the start and then use it for the tips and different aspects. I used the Phonegap Prompt notification. It’s working well now but does not test well in the simulator. As it asks for the name before going on to the game screen that’s going to be a little annoying, I’ll have to comment it out and then hard code a name for the testing.

The code itself is pretty easy to implement though.
function getUsername()

        {

        navigator.notification.prompt(

        ‘Please enter your name’,  // message

        onPrompt,                  // callback to invoke

        ‘What\’s your name?’,            // title

        [‘Ok’,’Exit’],             // buttonLabels

        ”                 // defaultText

    );

function onPrompt(results) {

        if (results.buttonIndex == 2){return;}

        if (results.input1 == ”){return;}

        localStorage.setItem(‘yourName’, results.input1);

         //Edit below
        // > do not use, will open in inappbrowser: window.open(“game.html”)
                window.location = “game.html”; //use this instead
        }

You can see I’m setting the input result into local storage so the player will not have to retype it each time they play. Come to think of it could make a small list of players they can select from, or and a new player. Might be a nice feature for down the road.

Edit, ok, so I just noticed if you use the window.open it loads in the inappbrowser window instead of the view, so this was changed above to the window.location call.

GapDebug is just cool

As I use the MyEclipse IDE for a lot of my development now it appears they have just released a new tool called GapDebug. This tool allows you to test and debug on the device in real time. Once setup, which was really easy, you just run a phoneap app and it shows up in the debugger ( which is Chrome based so you need that installed, one of the fees steps). Your device is connected though the USB cable. Once in debugging mode you can see the entire layout of the app, click on the and view the files and even edit in real time much of it, for example to test a new code or attribute.

I will be writing more on this, but since I just installed it this morning I want to play around with it more.

However it is a free tool so you can grab yours and play around as well!

Check out GapDebug now!

Oh, make sure to disable sleep mode, or it disconnects, but even if you don’t just wake it back up and it reconnects fine.