首页 > > 详细

辅导Android Development、java编程语言调试、Java讲解 调试Matlab程序|辅导Python编程

Assignment 4: Android Development
In this assignment you will build a simple Android app similar in spirit to the one shown at the end of the demo for the Android lesson. The app is a cipher tool that:
1.Takes as input:
a.A Message to be encoded.
i.This input should be a non-empty string and must contain at least one letter.
ii.This input should be provided to the app through an EditText widget, initially blank.
b.A Target Alphabet.
.This input should be a choice between “Normal”, “Reverse”, and “QWERTY”.
i.This input should be provided to the app through a spinner widget, initially set to “Normal”.
c.A Shift Number.
.This input should be an integer >= 1 and < 26.
i.This input should be provided to the app through EditText widget, initially set to ‘0’.
2.Produces as output 
a.The Ciphertext, which is the string resulting from using the specified alphabet and shift number to encrypt the input string.
.The letters in the message (a-z, A-Z) will be first mirrored onto the target alphabet, and then shifted by the number of characters specified by the Shift Number.  For the “Normal” alphabet, this will result in a Caesar Cipher, with the “Reverse” alphabet resulting in a Reverse Caesar Cipher.
i.An example of mapping the letters to the target alphabets (before any shift) following the English alphabet, the reverse of the alphabet, and the QWERTY keyboard layout:

Normal A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Reverse Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
QWERTY Q W E R T Y U I O P A S D F G H J K L Z X C V B N M

iii.Each letter in the message will then be shifted forward by the shift number.  An example of each alphabet shifted by 3:
Original Text A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Normal +3 D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Reverse +3 W V U T S R Q P O N M L K J I H G F E D C B A Z Y X
QWERTY +3 R T Y U I O P A S D F G H J K L Z X C V B N M Q W E

As an example, “Cat” mapped to the QWERTY alphabet and shifted 3 positions would be “Yrv”.
iv.All non-alphabetic characters remain unchanged.  Capitalization from the original message is preserved.  

EXAMPLE:
“Cat & Dog” shifted according to the Normal Alphabet and Shift Number 2 would be “Ecv & Fqi” (C+2, a+2, t+2, ‘ ‘, &, ‘ ‘, D+2, o+2, g+2).
“Cat & Dog” shifted according to the Reverse Alphabet and Shift Number 2 would be “Vxe & Ujr” (C->X+2, a->z+2, t->g+2, ‘ ‘, &, ‘ ‘, D->W+2, o->l+2, g->t+2).

This output should be shown using a non editable text field initially blank and (re)computed automatically whenever the button is pressed. If any input is invalid when the button is pressed, the output should then be set to “” (i.e., the empty string), and ALL applicable error messages should be set.

Error Messages
If the user provides an invalid input (see Item 1 above for what constitutes correct input values), the app should display an error message on the appropriate EditText widget using the error capabilities provided by the EditText widget. The error messages should be exactly (1) “Invalid Message”, applied to the Message field, (2) “Missing Message”, applied to the Message field, or (3) “Invalid Shift Number”, applied to the Shift Number field for (1) a letterless string Message, (2) an empty Message, and (3) a blank or out of range Shift Number.  If you do this correctly, the results should be a floating text error message (whenever the field has focus), with error mark “”, right next to the EditText , as shown in the error Screenshots below.  If you have set multiple applicable errors, then all error marks will show, but the error message will only show whenever the field has focus.  In addition, you may either limit the input in the numerical field to positive numbers through parameters on the input field, or provide the same error message for negative numbers and non-numerical input.

Below are several (slightly cropped) screenshots of the app that provide examples of normal behavior and errors. You should also treat the screenshots as example test results and use them to check that your app behaves as intended.
      
We suggest that you try to keep your user interface (UI) similar to the one shown, but you don’t have to. However, you must make sure to use exactly the same identifiers that we show in the next figure for the key widgets in the UI. This is very important, as we will use these identifiers to automatically test your app. The labels shown in the example UI are optional, but if included they must be separate from your required input and output fields.  Do not add additional text into the input and output fields aside from the actual input and output.  The identifiers are also listed next to the next figure for your (copy-and-paste) convenience.
Identifiers:
"messageInput"
“shiftNumber”
“targetAlphabet”
“encryptButton”
"cipherText"

For example, in the XML layout file for your app, the entry for the text field used to input the Message should have the following ID: android:id="@+id/messageInput". 

Please note that, as described in the detailed instructions below, we took some steps to help you make sure that you used the right identifiers and strings.

Detailed Instructions
To complete the assignment you must perform the following tasks:
1.In the root of your assigned individual GitHub repository, create a directory called Assignment4. Hereafter, we will refer to this directory in your local repo as
2.Using Android Studio, create an Android app project called “SDPEncryptor” in . Choose ‘Add No Activity’ if asked for a default activity. Check that this generates a directory SDPEncryptor under as the save location.

If your project set up asks for the package name, enter edu.gatech.seclass.sdpencryptor.  If it asks for the company domain, enter “seclass.gatech.edu”, which will result in the package edu.gatech.seclass.sdpencryptor. Verify that the package name is correct after your project is created.   
3.Select “API 23: Android 6.0 (Marshmallow)” as the minimum sdk for your app.  
This minSdkVersion should be reflected in your build.grade file in the project.
Your targetSdkVersion and compileSdkVersion will default to the latest SDK that you have downloaded, which will probably be ‘29’.  This is fine.
4.Create an “Empty Activity” and call it SDPEncryptorActivity
5.Download and save the archive available here, which contains three files provided to help you make sure that you used the right identifiers and strings, as we mentioned above. These files will not check everything for you, but if you use them, they will prevent many simple errors. The files, which we describe how to use in the rest of the steps, are:
oSanityCheck.java prevents your app from compiling if certain identifiers, your activity name, or your package name are incorrect. 
ostrings.xml provides some constant strings that you can reference to avoid typos in error messages. You are welcome to edit this file, omit it, copy from it, or add additional strings to it, but please keep in mind that our tests will expect the identifiers and error messages to match the ones provided, exactly.
oAssignmentExamples.java contains Espresso tests similar to the tests we will run on your code for grading.
6.Extract strings.xml from the archive and copy it to your project at /SDPEncryptor/app/src/main/res/values
7.Implement the primary functionality of the app in SDPEncryptorActivity. Note: You will need to make any function that your button calls is ‘public’, not ‘private’ in order to use the Espresso tests.
8.Define the IDs for the key widgets in the app as described above.
9.Extract SanityCheck.java from the archive and copy it to your project at /SDPEncryptor/app/src/main/java/edu/gatech/seclass/sdpencryptor
oRebuild the project in Android Studio.
oIf the project does not compile, and you have added all the required identifiers to your layout, it should mean that there are issues with your activity name/package, your identifiers, or both. Make sure to correct your project, and not the provided SanityCheck.java file.
10.Extract AssignmentExamples.java from the archive and copy it to your project at /SDPEncryptor/app/src/androidTest/java/edu/gatech/seclass/sdpencryptor
oAdd the necessary dependencies to your build.gradle.  This usually requires adding:
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
And making sure that the testInstrumentationRunner in the same file is set as:
 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
oRebuild the project in Android Studio
oRun the tests by either setting up a new run configuration or right clicking the file and choosing “Run ‘AssignmentExamples’”.
12.Create a manual.md file (in Github flavored MD format) that describes how to use the app. Put the file in , not in SDPEncryptor. Think of this file as a (very concise) user manual. You should not need more than one page for the manual. It should use at least some markdown formatting.  Feel free to add screenshots to the manual, but that is not mandatory.  You can view your markdown file in Github or using an MD viewer.
13.Commit and push your project from within Android Studio or from the command line.   Doing it from Android Studio should help ensure that all the required files are committed. Be sure to use your existing, assigned repository, rather than creating a new repository from Android Studio. No matter how you commit and push your project, we strongly recommend that you ensure you have pushed all the necessary files by (1) cloning your repo in a different directory, (2) opening the project in Android Studio from this new directory, (3) compiling the project, and (4) running it on a (virtual) device that does not already have the app installed (i.e., you may have to remove the app from the device if you have run the app there before).  
14.As usual, submit your solution by doing the following:
oPushing your code to your assigned remote GitHub repository.
oSubmitting the final commit ID for your submission on Canvas. (You can get your commit ID by running "git log -1" and copying the hexadecimal ID it produces.)
Notes
You should commit early and often.  Verify that you are able to correctly push your code to the assigned repository as soon as possible.  You can perform multiple commits and work on multiple branches as you produce your solution. This is not only fine, but actually encouraged. Just make sure that your final solution is committed to the master branch.
You should complete the assignment using Android Studio 3.*. Earlier versions of Android Studio may work as well, but we have not tested our solution there.
Feel free to take inspiration from online resources when developing your app. However, be careful not to copy and paste entire pieces of functionality. The tool we use to identify cases of plagiarism is likely to have access to the same online resources that are available to you.
Do not add field labels or any extra text into the designated EditText fields.  Each EditText field should contain only the relevant input or output.  You may use other fields for optional labels or UI elements.
In case you want to use automated testing for your app, you may find Espresso and Android Studio Test Recorder useful. This is completely optional; that is, developing tests for your app, whether manual or automated, is not required.  
If you decide to use Espresso yourself, or run our provided tests, here’s a couple of potentially useful tips:
oIf anything covers your fields or buttons (even invisible boxes), the tests may fail to complete.
oIf you use buttons that call private methods, Espresso will be unable to click the button.  Make sure the method your encrypt button calls is public.
oTurn off animations in your AVD, particularly if the tests return AmbiguousViewMatcherException.
oYou may need to turn off the autofill feature or spellcheck in your AVD if your tests fail due to auto-completion of text input.

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!