Android代写:COMPS311 Android App

完成一个Android应用程序,做一个小费计算器。

Android

Question 1 - Basics and resources

In this question, you create an Android app that displays your information according to the following requirements.

  • The name of the app is “My Name”, and the package name of the app (i.e. app id)
  • By default, the app displays your name in English and your student ID.
  • If the locale of the device is traditional Chinese - Hong Kong, the app displays your name in Chinese and your student ID.

The following are sample outputs when the app is executed in locales of English (left) and traditional Chinese - Hong Kong (right), respectively.

Submit one whole Android project that contains all your work for this question.

Question 2 - Layout and UI

Unit 6 contains an example app of a tip calculator. Enhance the app according to the following screenshots and requirements.

  • a. Modify the portrait layout (existing in the project) to add 12 buttons under the “Bill Amount” input field, as shown in the left screenshot above.
  • b. Create a new landscape layout that contains the same components in the portrait layout (with the same IDs). Design the layout so that the components work properly in the landscape device orientation.
  • c. Implement the event handlers of the 12 new buttons as follows.
    • For each of the digit buttons, i.e., “1”, “2”, “3”, …, “9”, and “0”, append the digit of the clicked button to the bill amount input field.
    • For the “.” button, append a dot “.” to the bill amount input field if it has no
      “.” yet. (Nothing happens if a “.” already exists in the field.)
    • For the “[-“ (backspace) button, remove the last character from the bill amount field if it is not empty. (Nothing happens if the field is empty.)
  • d. Create an “About” options menu item and show it as an action item. You may use a built-in Android drawable resource as its icon. When the item is selected, an “About” dialog box appears to show your name and your student ID, as in the middle screenshot above.
  • e. Create three options menu items “No fractional digits”, “One fractional digit”, and
    “Two fractional digits”. These menu items are checkable, mutually exclusive, and in a group. They control the number of digits displayed after the decimal point for the output fields of “Total Bill Amount” and “Total Per Person”. The right screenshot above shows the output fields with one fractional digit.

For simplicity, you may hard-code new strings in the programs, and don’t need to use primary or alternative string resources for them. Submit one whole Android project that contains all your work for this question.

Question 3 - Fragments, networking and concurrency

In this question, you develop an Android that checks the status of Web pages. A skeleton project, called WebChecker, is provided to you. Complete the project by working through the following tasks.

  • a. In the MainActivity class, create and show the MainFragment when the app starts. The main screen is similar to the left screenshot shown below.
  • b. In the CheckerFragment class, set up the “Go To” button to view the Web page at the input URL. Use an Intent to invoke the browser app.
  • c. In the CheckerFragment class, set up the “Check” button to check the status of Web page at the URL. Display the HTTP response code and message in the status field; in case of error, display the error message instead.
  • d. In the CheckerFragment class, append a log message to the MainActivity’s log object (StringBuilder) after checking a URL. For a valid response, the log message contains the date/time of logging, the URL address, the response code, and the response message; in case of error, the log message contains the date/time of logging, the URL address, and the exception error message. Refer to the right screenshot below for some example messages.
  • e. Create a LogFragment class and its associated fragment_log.xml layout, for displaying the MainActivity’s log messages. Refer to the right screenshot below.
  • f. In the MainFragment class, set up the “View Log” button to create and show the LogFragment.

The following screenshots show the main screen (left) and log message screen (right) of the app. Submit one whole Android project that contains all your work for this question.