Author Archives: Anonymous

Profile Pictures

Now that the user system was up I could add in profile pictures. For this I added a profile page which would hold the profile picture, buttons to let you upload a new picture, and a button to go to the map. The first step was letting the user pick the picture they wanted to use from the picture gallery on their phone. For this I used the Xam.Plugin.Media plugin which provides that functionality for Android and iOS. Next I added a new Table to the sql server which would store a persons username and their profile picture in a BLOB. BLOB stands for binary large object and is used to store large chunks of data. So the way it would work is a user would tap the upload picture button select a picture using the Media plugin that would then give us the picture converted into a byte array. The data in the array and the users username would then be stored in the sql server.

Next I had to take care of how someone would look like without a profile picture. I didn’t want to store a picture on the server for every person that didn’t have a profile picture so I found a “no avatar” picture and stored it in the resource folder on both iOS and Android. So when somebody that hadn’t uploaded a profile picture posted their location or went to their profile page the “no avatar” would be loaded from resources.

The final problem to take care of was having a uniform size for the profile pictures. For this I needed to be able to resize the pictures before storing them in the database. I tried using a plugin for it but the plugin would always maintain the aspect ratio of image meaning I would always get images with varying sizes. So instead I decided to code my own image resizer. The way this works is you write an interface in the shared code and then write two classes that extend it, one in the Android code and one in the iOS. Then when calling a method from the class you use Xamarins DependencyService which selects the correct class for you depending on what system its running on. So using this I wrote my own ImageResizer class that took an image byte array and resized it to whatever size I needed.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.

Login Page and User System

The next thing to focus on was setting up a user system. For this I drew up a login page and added a User table to the sql server which holds the username and password. For a user system I would need to be able to create an account, check that the username used to create doesn’t exist, and, if the account already exists, check that the password is correct. All of this is done in php by polling the sql server. Once I got logging in to work I needed to make sure everything you do in the app is tied to your username. Which meant, for now, passing the username between pages and adding a username field to the Location table. Now locations stored in the server would also have the persons username attached to them. This let me add another button to the map that lets you only retrieve locations that you put down. Now that I had a user system in place I could start working on the more complicated aspects of the project.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.

Login Page and User System

The next thing to focus on was setting up a user system. For this I drew up a login page and added a User table to the sql server which holds the username and password. For a user system I would need to be able to create an account, check that the username used to create doesn’t exist, and, if the account already exists, check that the password is correct. All of this is done in php by polling the sql server. Once I got logging in to work I needed to make sure everything you do in the app is tied to your username. Which meant, for now, passing the username between pages and adding a username field to the Location table. Now locations stored in the server would also have the persons username attached to them. This let me add another button to the map that lets you only retrieve locations that you put down. Now that I had a user system in place I could start working on the more complicated aspects of the project.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.

Login Page and User System

The next thing to focus on was setting up a user system. For this I drew up a login page and added a User table to the sql server which holds the username and password. For a user system I would need to be able to create an account, check that the username used to create doesn’t exist, and, if the account already exists, check that the password is correct. All of this is done in php by polling the sql server. Once I got logging in to work I needed to make sure everything you do in the app is tied to your username. Which meant, for now, passing the username between pages and adding a username field to the Location table. Now locations stored in the server would also have the persons username attached to them. This let me add another button to the map that lets you only retrieve locations that you put down. Now that I had a user system in place I could start working on the more complicated aspects of the project.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.

Login Page and User System

The next thing to focus on was setting up a user system. For this I drew up a login page and added a User table to the sql server which holds the username and password. For a user system I would need to be able to create an account, check that the username used to create doesn’t exist, and, if the account already exists, check that the password is correct. All of this is done in php by polling the sql server. Once I got logging in to work I needed to make sure everything you do in the app is tied to your username. Which meant, for now, passing the username between pages and adding a username field to the Location table. Now locations stored in the server would also have the persons username attached to them. This let me add another button to the map that lets you only retrieve locations that you put down. Now that I had a user system in place I could start working on the more complicated aspects of the project.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.

Login Page and User System

The next thing to focus on was setting up a user system. For this I drew up a login page and added a User table to the sql server which holds the username and password. For a user system I would need to be able to create an account, check that the username used to create doesn’t exist, and, if the account already exists, check that the password is correct. All of this is done in php by polling the sql server. Once I got logging in to work I needed to make sure everything you do in the app is tied to your username. Which meant, for now, passing the username between pages and adding a username field to the Location table. Now locations stored in the server would also have the persons username attached to them. This let me add another button to the map that lets you only retrieve locations that you put down. Now that I had a user system in place I could start working on the more complicated aspects of the project.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.

Login Page and User System

The next thing to focus on was setting up a user system. For this I drew up a login page and added a User table to the sql server which holds the username and password. For a user system I would need to be able to create an account, check that the username used to create doesn’t exist, and, if the account already exists, check that the password is correct. All of this is done in php by polling the sql server. Once I got logging in to work I needed to make sure everything you do in the app is tied to your username. Which meant, for now, passing the username between pages and adding a username field to the Location table. Now locations stored in the server would also have the persons username attached to them. This let me add another button to the map that lets you only retrieve locations that you put down. Now that I had a user system in place I could start working on the more complicated aspects of the project.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.

Login Page and User System

The next thing to focus on was setting up a user system. For this I drew up a login page and added a User table to the sql server which holds the username and password. For a user system I would need to be able to create an account, check that the username used to create doesn’t exist, and, if the account already exists, check that the password is correct. All of this is done in php by polling the sql server. Once I got logging in to work I needed to make sure everything you do in the app is tied to your username. Which meant, for now, passing the username between pages and adding a username field to the Location table. Now locations stored in the server would also have the persons username attached to them. This let me add another button to the map that lets you only retrieve locations that you put down. Now that I had a user system in place I could start working on the more complicated aspects of the project.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.

Setting Up SQL, PHP, and Sending/Loading Locations

After displaying a map the next thing to do was to let the user send their location and be able to store it. For this I used 000webhost a hosting site that provided me with a MySQL server and PHP scripting to manage it. Using the System.Net.Http Plugin in Xamarin I wrote code that would post the latitude, longitude, and place name in JSON to a php file located on my site. The file would then convert the JSON into variables, stick them into a sql call, and execute the sql against the MySQL database to store them inside the Location table. To do this I needed a way to get the users location on iOS and Android. This functionality was provided by the Xam.Plugin.Geolocator Plugin. Also I needed a way to show a popup asking for the name of the location. For this I used Acr.UserDialogs Plugin. So after putting everything together the user would be able to tap an add button which would poll Geolocator for their location, then type in the name of their location and tap Ok, which would send and store the data in the MySQL server.

Next I needed to be able to get the locations from the server and display them on the map as pins. The process works almost the same way but backwards. You pull the data from the sql database using php encode it in JSON and send it back. The only difference would be decoding the JSON on the other side. Using the plugin Newtonsoft.Json you could decode the JSON string, but what makes the plgin convenient is that you can decode the JSON straight into an Object that will hold the data. For example I created the Object LatLonPair that would hold latitude, logitude and name variables. So using Newtonsoft you could decode a json string into an array of LatLonPairs that hold all your data. From their displaying on the map is easy. just iterate over the array and place the pins on the map.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.

Setting Up SQL, PHP, and Sending/Loading Locations

After displaying a map the next thing to do was to let the user send their location and be able to store it. For this I used 000webhost a hosting site that provided me with a MySQL server and PHP scripting to manage it. Using the System.Net.Http Plugin in Xamarin I wrote code that would post the latitude, longitude, and place name in JSON to a php file located on my site. The file would then convert the JSON into variables, stick them into a sql call, and execute the sql against the MySQL database to store them inside the Location table. To do this I needed a way to get the users location on iOS and Android. This functionality was provided by the Xam.Plugin.Geolocator Plugin. Also I needed a way to show a popup asking for the name of the location. For this I used Acr.UserDialogs Plugin. So after putting everything together the user would be able to tap an add button which would poll Geolocator for their location, then type in the name of their location and tap Ok, which would send and store the data in the MySQL server.

Next I needed to be able to get the locations from the server and display them on the map as pins. The process works almost the same way but backwards. You pull the data from the sql database using php encode it in JSON and send it back. The only difference would be decoding the JSON on the other side. Using the plugin Newtonsoft.Json you could decode the JSON string, but what makes the plgin convenient is that you can decode the JSON straight into an Object that will hold the data. For example I created the Object LatLonPair that would hold latitude, logitude and name variables. So using Newtonsoft you could decode a json string into an array of LatLonPairs that hold all your data. From their displaying on the map is easy. just iterate over the array and place the pins on the map.

From the blog Location App Blog by Anonymous and used with permission of the author. All other rights reserved by the author.