tasti / android-coding-challenge

Android Coding Challenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android Coding Challenge

Attached is a simple program server.py that, when started, listens at port 1234 for incoming socket connection.

After a client connects, the server will spit out a stream of messages.

Protocol

Each message is a "color command", which the client should use to change the color of the interface in real-time.

The color of the interface is represented by 3x 8-bit values, R, G and B. The connecting client is supposed to keep state of the current color. Upon connect, the color should be reset to (127, 127, 127).

There are 2 command types, relative and absolute.

Relative

The relative command, changes the components with a relative offset. The message has this structure:

  • 8-bit constant -- 0x01 ("relative" command)
  • 16-bit signed int, network endian -- R offset
  • 16-bit signed int, network endian -- G offset
  • 16-bit signed int, network endian -- B offset

The offset fields are 16-bit for future purposes.

Upon receiving a "relative" command, the client is supposed to offset the current components with the given offsets.

Absolute

The absolute command, changes the components to the specified absolute values. The message has this structure:

  • 8-bit constant -- 0x02 ("absolute" command)
  • 8-bit unsigned int -- absolute R value
  • 8-bit unsigned int -- absolute G value
  • 8-bit unsigned int -- absolute B value

Upon receiving a "absolute" command, the client is supposed to set the current components to the given absolute values.

Challenge

Write an Android application that can connect to the server.py program, and interpret the incoming messages.

Allow the user to enter the IP address of the server.

In the user interface, list recent commands as they are received.

Allow a command to be selected.

As commands are received, you should "sum up" the selected commands.

Selection rules:

  • When a new command is received, that command should be selected by default.
  • At any time, one absolute command must be selected plus any number of relative commands.
  • If the received command is "absolute", all previously selected commands should be deselected.
  • A user should also be able to manually select or deselect commands, subject to the above rules.

Displaying the RGB value:

  • The current RGB value should be calculated from the selected commands.
  • Display the current RGB value numerically, and so set some UI element to that value

Evaluation

Design goals in order of importance:

  • Clean, well-structured code. Good separation of concerns.
  • Low memory footprint.
  • Speed.

The visual presentation of the application is not being evaluated. You will not lose any marks if it looks ugly.

Bonus points for an aesthetically pleasing app, but don't make the code unnecessarily complicated.

You are only allowed to use the standard Android frameworks.

As a reference: The server.py program prints the expected current RGB values to stdout, just before sending out the next command.

About

Android Coding Challenge


Languages

Language:Java 90.8%Language:Python 9.2%