Due: Friday February 19, 11pm
Upload Instructions: Upload your solution here.
In this assignment, you have to build an app that enables you to group chat anonymously with people nearby.
You are going to use the following server API.
Base URL: https://luca-teaching.appspot.com/localmessages/default/
Parameters:
Example:
https://luca-teaching.appspot.com/localmessages/default/post_message?lat=9.9993&lng=10.0004&user_id=31&nickname=Hobbes&message=Tuna&message_id=8755
{"result": "ok"}
Parameters:
This returns a certain number of local messages, in arbitrary order.
Example:
https://luca-teaching.appspot.com/localmessages/default/get_messages?lat=9.99999&lng=10.0001&user_id=39
{"result_list": [{"timestamp": "2016-02-09T00:42:27.823020", "message": "Tuna", "nickname": "Hobbes", "user_id": "31", message_id=8755}, {"timestamp": "2016-02-09T00:41:53.328900", "message": "Holaaaa", "nickname": "PeterPan", "user_id": "38"}, {"timestamp": "2016-02-09T00:34:24.536050", "message": "Holaaaa", "nickname": "PeterPan", "user_id": "38", message_id=8755}], "result": "ok"}
You have to develop an app that behaves as follows.
The app consists of two activities, MainActivity and ChatActivity.
In MainActivity, the first time, you create for yourself a random user_id and you store it in the Preferences.
Then, you ask the user to enter a nickname, and you acquire the location.
Once both the user has entered a nickname, and the location is known to 50m or better, you enable the Start Chat button. When pressed, the Start Chat button stores the nickname in the app preferences, and leads to ChatActivity.
Look
In the chat activity, at the bottom there is a place where you can post a message, and a button that you can use to refresh the list of messages.
Above, there are the various messages. You need to display the messages in chronological order (newest at the bottom), and you need to have some way of distinguishing the messages that are from you, and the messages that are from others. For this purpose, you can compare the user_id of each message with your own user_id (which you can find in the preferences).
Behavior
When the user clicks "refresh", you need to refresh the list of messages (using API method get_messages).
When the user types a new message and clicks Send, you have to:
ADVANCED: When the post_message call returns {"result": "ok"} you can remove the icon or text treatment you used to indicate that the sending is still pending, and you can display the sent message like all other sent messages.
Start early! Besides this, you can find sample code for almost all you need to do.