COMP3059 - Coursework 1- Fingerpainter

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due

COMP3059 - Coursework 1- Fingerpainter

Summary

In this exercise, you are required to build an Android painting application. This is an assessedexercise and will account for 30% of your final module mark. This is an individual coursework, and your submission must be entirely your own work – please pay particular attention to the section of this document regarding plagiarism. This document sets out the requirements and broad instructions for developing the application.

Your application should be submitted no later than:

  • Tuesday, 4:00 pm, April 01, 2025

Submissions should be made electronically via Moodle. Standard penalties of 5% per working day will be applied to late submissions. This coursework will not be assessed using a physical

Android device. It is sufficient to use the emulator for testing. Hints and tips are given from page 4 to page 7.

Specification

You should create an application to support a simple drawing/painting task, where the user can draw on a canvas using their finger in a variety of colors and with brushes of different sizes and shapes. The user should either begin with a blank canvas or be able to draw over an existing image in the device’s Any (Internal/External) folder that will be loaded by the application. The user is also able to save the painted image with a maximum of 10 characters of any user-given name in the folder from where the original image (without painting) opened or in the Download folder if the user painted on a blank canvas.

Your application must consist of three Activity components:


  • An Activity presenting the FingerPainter interface for the user:
    • Allows the user to download an image from any URL in the Download folder and shows it up on the Activity for painting on it.o Allows the user to draw on a canvas using their finger in a variety of colors and with brushes of different sizes and shapes. The user should either begin with a blank canvas or be able to draw over an existing image in the device’s Any (Internal/External) folder that will be loaded by the application.
  • Allows the user to save painted images with a maximum of 10 characters of any user-given name in the folder from which the original image (withoutpainting) opened or in the Download folder if the user painted on a blank canvas.
  • Allows the user to Undo the last painting task and Redo the last Undo painting task.
  • An Activity allowing the user to select the color with which to draw.
  • An Activity allowing the user to select the shape and size of the drawing brush.


Furthermore, the application should:
  • Support appropriate lifecycle persistence of Activity UI state.
  • The application can be opened from and displays an image from any folder on the device for painting.
A custom painting View is provided that must form the basis of the application. It is left up to you to decide how best to design and implement layouts and other views within theseactivities.

Your application must be written in Java and make use of the Android SDK. Your application will be tested on an emulated device (1080 x 1920 420dpi) running Android API version 30 (Android 11.0).

Assessment Criteria

The marking scheme will be as follows:
Testing criteria (90%)
  • Requirement tests (60%): Your program should correctly implement the task requirements. The marks will be awarded for achieving specific functionality as follows. There are no additional marks available for additional functionality in thisexercise:
    • The application can download an image from a URL and show it up on the activity for painting on it.
    • The application has an Activity that allows the user to paint on a blank canvas o an image from any folder on the device. The canvas must be square-shaped in both cases.
    • A second Activity allows the user to select one of at least 5 colors.
    • A third Activity allows the user to select one of at least three shapes and at least five sizes of the brush.
    • The currently chosen color should be passed from the painting Activity to the color-choosing Activity and displayed by the color-choosing Activity.
    • The current shape and size of the brush should be passed from the paintingActivity to the brush-choosing Activity and displayed by the brush-choosing Activity.
    • The painting Activity maintains color and brush state as appropriate throughout its expected lifecycle.
    • The application can be opened from and displays an image from any folder onthe device for painting.
    • The application can save the painted image with a maximum of 10 characters ofany user-given name in the folder from where the original image (without painting) opened or in the Download folder if the user painted on a blank canvas.If the user inputs more characters than the maximum limit, the App will display a Toast message “Number of characters is more than the maximum limit”.
    • The application can undo the last painting task and redo the last Undo paintingtask.
  • Appropriate use of language features (30%): Your program should use theappropriate Android features in your solution. You can use any Android features ortechniques that you have seen in the course, or you have learned on your own, aslong as they are appropriate for your solution. Examples of this might be:
    • Decomposition of the task into logical, discrete Activity components.
    • Appropriate use of Activities, Intents, and appreciation of the Activity lifecycle.
    • Appropriate use of Widgets and ViewGroups for layouts that support differentscreen orientations.
    • After screen rotation, all the view components including the canvas will be still visible and proportionally scaled and aligned in different screen orientations.
    • Your application should be working persistently after screen rotation.
    • Appropriate use of Services, and appreciation of the Service life-cycle.
    • Your application should have appropriate comments and variable/classnames so that a reader can easily understand how it works at the code level.
If your application does not build or APK doesn’t run then you will lose all testingmarks (90% marks). i.e. you should submit a complete Android project with all theconfiguration and resource files. Your project should be imported, built, and run on Android Studio, otherwise, you will lose all testing marks (90% mark).

Source code formatting (10%): Your program should be correctly formatted and easy to understand by a competent Android programmer. This includes but is not limited to,indentation, bracketing, class/variable/function naming, and use of comments.

Please note that this coursework will be primarily assessed on the above specification, andfurther additions must not detract from the required functionality given above.

Plagiarism

N.B. Use of third-party assets (tutorials, images, example code, libraries, etc.) MUST becredited and referenced, and you MUST be able to demonstrate that they are availableunder a license that allows their reuse.

Making significant use of tutorial code while referencing it is poor academic practice, andwill result in a lower mark that reflects the significance of your own original contribution.

A strong warning to the students against using ChatGPT or other AI tools, firstly, because itis an academic offense and, secondly, in any case, ChatGPT is not reliable and does notalways give the correct answer. Copying code from other students, from previous students, from any other source (including ChatGPT or other AI tools), or soliciting code from onlinesources and submitting it as your own is plagiarism and will be penalized as such. This canpotentially result in failure of coursework, module, or degree.

All submissions are checked using both plagiarism detection software and manually forsigns of cheating. If you have any doubts, then please ask.

Submission

There are two separate requirements for a complete submission of this coursework:


  • Source Code - You must submit a ZIP file named zy12345.zip (where zy12345 is your email prefix, the part before @ of your university email ID). This ZIP file should contain all the necessary materials to build your application. Do not submit RAR files.
  • APK - You should submit an APK file name zy12345.apk (where zy12345 is your email prefix, the part before @ of your university email ID). The APK file should be a self contained application that the marker can install on a (virtual and physical) Android device in order to test the functionality of your application.


You must submit all two of these components for your submission to be considered "complete". Failure to do so will result in a 50% deduction for each submission component that is missing from your "complete" submission.

Instructions
Finger Painting

Begin by creating a new application in Android Studio as usual.

Add the custom view FingerPainterView to your app project. This class is available on Moodle.

You can either copy the file directly into your project’s source directory (projectname/app/src/main/java/…) or create a new FingerPainterView Java class in your project and copy / paste the code into it, updating the package qualifier accordingly.

Add an instance of the FingerPainterView to the layout of your main activity. You can do this either statically through its XML layout resource (Containers-> <view> ->FingerPainterView) Or add it to an appropriate ViewGroup programmatically when the activity is created.

FingerPainterView

FingerPainterView should automatically create a square paintable canvas that fills the view space that is given and responds to touch (“mouse”) events by drawing lines onto its internal bitmap. This bitmap is automatically persisted to a cache file.

The class has a few public set / get methods for managing the color and shape of the brush: public void setColour(int colour) …sets the colour of the brush, where colour is of the form 0xAARRGGBB for setting alpha, red, green, and blue values respectively. Alpha should always be 255, i.e. 0xFF. For example, to set the drawing colour to green: myFingerPainterView.setColour(0xFF00FF00);

Or:
import android.graphics.Color;
myFingerPainterView.setColour(Color.GREEN);
myFingerPainterView.setColour(Color.parseColor("#FF00FF00"));
To set the shape of the brush:

public void setBrush(Paint.Cap brush)

Where the brush is either round or square, defined by the Paint.Cap enum: import android.graphics.Paint;
Paint.Cap.ROUND
Paint.Cap.SQUARE
To set the width of the brush:
public void setBrushWidth(int width)
Where width is an integer value in pixels.
The equivalent get methods allow you to retrieve the current state of these values. They are not persisted by the view between instances.

The Task

Create two new activities to allow the user to specify the color, size, and shape of the brush respectively.

The current color and brush size/shape should be respectively passed from the painting activity to the color and brush selection activities– i.e. the color/brush selection activity should know and display the current color/brush size and shape that the user is currentlyusing. It is left up to you to create appropriate interfaces to allow the user to select a color and brush (they need to input either a SQUARE, ROUND, or STROKE brush, and a width in pixels) and return these values to the main activity.

The ‘Finger Painter’ activity needs to have a component to allow the user to download an image from a URL and the image will be displayed on the activity automatically for painting on it by the user.

The ‘Finger Painter’ activity needs to have a component to specify an image name of a maximum of 10 characters and a button to actually save the painted image in the current folder with the specified name. If the user inputs more characters than the maximum limit the App will display a Toast message “Number of characters is more than the maximum limit”.

The ‘Finger Painter’ activity needs to have two components, one for undoing the last painted task on the image or blank canvas and another for redoing the last undone painting task.

Persistence

FingerPainterView takes care of persisting its own internal bitmap state if it happens to be destroyed – it saves the current picture to a cache file – however the state of other components, for example, the current color and brush selection does not persist. You should handle the relevant activity lifecycle events for your activities to ensure a coherent user experience if, for example, when the device is rotated.

Implicit Intent

Finally, as in the task diagram above, the user should be able to select an image in another application (e.g., File application) and choose to open it with your FingerPainter app. To support this our application should respond to implicit Intentsthat conform to something that we can open – in particular when the user attemptsto view a file that happens to be an image.

The aim here is to, when browsing through their files using the Files application, give the user the option of opening a file in our FingerPainter beside the other applications, such as the

Picture Viewer. We should do this by registering our application as being able to receive the appropriate intents.

If successful, you can test this by opening an image from any folder on the device, which should now give you the option of your app to open the image with, as well as other installed applications.

References

https://developer.android.com/guide/topics/ui/declaring-layout
http://developer.android.com/guide/components/activities.html
http://developer.android.com/guide/components/intents-filters.html
http://developer.android.com/reference/android/graphics/Color.html
http://developer.android.com/reference/android/graphics/Paint.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注