讲解:COMP3059、Java、data、JavaWeb|Web

COMP3059 - Coursework 1- FingerpainterSummaryIn this exercise you are required to build an Android painting application. This is an assessedexercise and will account for 20% of your final module mark. This is an individual coursework,and your submission must be entirely your own work – please pay particular attention to thesection of this document regarding plagiarism. This document sets out the requirements ofand broad instructions for developing the application.Your application should be submitted no later than:• 14 April 2020 @ 16:00Submissions should be made electronically via Moodle. Standard penalties of 5% per workingday will be applied to late submissions.Your application should be submitted as a .zip file containing all relevant source code,configuration and related files, and a compiled .apk file – i.e. the contents of the directorycontaining your Android Studio project after a clean rebuild. Do not submit RAR files.SpecificationYou should create an application to support a simple drawing / painting task, where the usercan draw onto a canvas using their finger in a variety of colours and with brushes of differentsizes and shapes. The user should either begin with a blank canvas or be able to navigate froman existing image in the device’s Downloads folder that will be loaded by the application.Your application must consist of three Activity components:• An Activity presenting the FingerPainter interface for the user to draw onto• An Activity allowing the user to select the colour with which to draw• An Activity allowing the user to select the shape and size of the drawing brushFurthermore, the application should:• Integrate with other applications to allow the user to draw on existing images as partof the drawing task• Support appropriate lifecycle persistence of Activity UI stateA custom painting View is provided that must form the basis of the application. It is left up toyou 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. There are norequirements to target a specific Android API version, however you can assume that yourapplication will be tested on an emulated device (1080 x 1920 420dpi) running Android APIversion 29 (Android 10.0).You should consider the following when implementing your application:• Decomposition of the task into discrete Activity components• Appropriate use of Intents, communication between Activities and appreciation of theActivity life-cycle• Appropriate use of Widgets and ViewGroups for layouts that support devices ofdiffering screen sizes and resolutions• Your application is expected to have appropriate comments and variable / classnames, so that a reader can easily understand how it works if necessaryAssessment CriteriaAs this is a constrained exercise marks are awarded for achieving specific functionality asfollows. For all elements either 0 or full marks are awarded as appropriate. There are noadditional marks available for additional functionality in this exercise:MarksThe application has an Activity that allows the user to paint onto a blank canvas 4A second Activity allows the user to select one of at least 5 colours 3A third Activity allows the user to select the shape and size of the brush 4The colour choosing Activity is passed and displays the currently chosen colour 2The brush choosing Activity is passed and displays the current shape and size ofthe brush2The painting Activity maintains colour and brush state as appropriatethroughout its expected lifecycle2The application can be opened from and displays an image from the Downloadsfolder on the device for painting3Total 20PlagiarismN.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.Copying code from other students, from previous students, from any other source, orsoliciting code from online sources and submitting it as your own is plagiarism and will bepenalized as such. FAILING TO ATTRIBUTE a source will result in a mark of zero – and 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.InstructionsFinger PaintingBegin 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 yourproject 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 thiseither statically through its XML layout resource (Containers-> ->FingerPainterView):Or add it to an appropriate ViewGroup programmatically when the activity is created:FingerPainterView myFingerPainterView = new FingerPainterView(this);myFingerPainterView.setId(R.id.myFingerPainterViewId);myFrameLayout.addView(myFingerPainterView);Note in either case the FingerPainterView must have an ID, otherwise the view will not receivethe cascaded save state calls (if a view does not have an ID the OS doesn’t know where itshould restore the view to on restore).If adding the FingerPainterView programmatically (that is, not via the XML layout but at runtime)you will need to create a static ID resource in res/values/strings.xml and assign it to theview on creation, otherwise the view will not receive the cascade代写COMP3059作业、代做Java语言作业、代写data课程作业、Java编程设计作业调试 调试Web开发|代写Wed save state calls correctly: FingerPainter If adding the FingerPainterView via the XML layout you must also remember to specify an IDto the view as using the attributes panel. You should retrieve and maintain a reference to thisView in the same way as the other views in lab exercise two (findViewById(…) if you’reinstantiating it via the layout resource).You may find it useful to nest the FingerPainterView inside a FrameView as in the code above,with its width and height matching that of the parent FrameView.FingerPainterViewFingerPainterView should automatically create a square paintable canvas that fills the viewspace that it is given, and responds to touch (“mouse”) events by drawing lines onto itsinternal bitmap. This bitmap is automatically persisted to a cache file.The class has a few public set / get methods for managing the colour 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 setthe 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 brush is either round or square, defined by the Paint.Cap enum:import android.graphics.Paint;Paint.Cap.ROUNDPaint.Cap.SQUARETo 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 arenot persisted by the view between instances.The TaskCreate two new activities to allow the user to specify the colour, and size and shape of thebrush respectively.Each of these activities should be passed the current colour and brush size / shaperespectively – i.e. the colour selection activity should know and display that the user iscurrently is painting in red. It is left up to you to create appropriate interfaces to allow theuser to select a colour and brush (they need to input either a SQUARE or ROUND brush, anda width in pixels) and return these values to the main activity.PersistenceFingerPainterView takes care of persisting its own internal bitmap state if it happens to bedestroyed – it saves the current picture to a cache file – however the state of othercomponents, for example the current colour and brush selection are not persisted. Youshould handle the relevant activity lifecycle events for your activities to ensure a coherentuser experience if, for example, the device is rotated.OpenImageFingerPainterSelectColourSelectBrushImplicit IntentFinally, as in the task diagram above, the user should be able to select an image in anotherapplication and choose to open it with your FingerPainter app. To support this our applicationshould respond to implicit Intents that conform to something that we can open – in particularthe user attempting to view a file that happens to be an image.Note that you can load files onto the emulator by downloading via the in-emulator webbrowser, pushing files onto the SD card via the Android Device Monitor tool from AndroidSDK, or on the command line using adb. Downloaded files are stored in /sdcard/Download/on the device.platform-tools$ ./adb push cats.jpg /sdcard/Download/cats.jpgcats.jpg: 1 file pushed. 21.6 MB/s (251024 bytes in 0.011s)platform-tools $The aim here is to, when browsing through their files using the Files application, give the userthe option of opening a file in our FingerPainter as opposed to other applications, such as thePicture Viewer. We should do this by registering our application as being able to receive theappropriate intents.Add a second intent-filter to the main activity in the AndroidManifest – so that the applicationcan either be started via the launcher or by an intent sent by another application.This filter should accept intents with an action of android.intent.action.VIEW, category ofandroid.intent.category.DEFAULT, and data of mimeType image/* android:mimeType=image/* />The location of the image to load will be delivered to the main activity via its intent, with theURI of the image being included in the data field of the intent. FingerPainterView will attemptto load an image by URI when called from the onCreate method:myFingerPainter.load(intent.getData());If successful, you can test this by opening an image from the Downloads app on the device,which should now give you the option of your app to open the image with, as well as otherinstalled applications.If you are targeting Android 10 (or Q, or SDK version 29), the FingerpainterView may cause acompilation error as below:The quick fix for this is to change the compileSdkVersion in the applications build.gradle filefrom 29 to 28. This will then prompt Android Studio to ask you to sync the project, which willfix the error.This error arises as bitmap.compress is now considered a function that takes some time andso should not be permitted to be called from the UI thread. The implication is that bitmapsshould not be saved via onSaveInstanceState, but unfortunately this is how FingerpainterViewis naively constructed.The preference for larger transient instance state is to persist this slightly differently usinga ViewModel. Here the simplest refactoring is for the FingerPainterView bitmap to be copiedinto a ViewModel onSaveInstanceState.Note: there is no expectation that you do this for the coursework.转自:http://www.daixie0.com/contents/9/4949.html

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,634评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,951评论 3 391
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 161,427评论 0 351
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,770评论 1 290
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,835评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,799评论 1 294
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,768评论 3 416
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,544评论 0 271
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,979评论 1 308
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,271评论 2 331
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,427评论 1 345
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,121评论 5 340
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,756评论 3 324
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,375评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,579评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,410评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,315评论 2 352

推荐阅读更多精彩内容