Lecture 3 & HW 3: Intents and Manifest

Lecture Demo Code:

Discussion: Google Slides, YouTube

Homework Instructions: Let’s make this interesting!

Last week, we built a color selector app. Now, it's a useful app by itself, but sometimes you might want a bit more functionality -- perhaps multiple utilities in an app, perhaps access to the world around it?. How about adding all of that to your existing app? Ready? Let’s go!

Objectives

You are tasked with modifying your existing color selector app from HW 2. If you have not completed HW 2 yet, or you are unconfident with your solution, we'll share a good "baseline" HW 2 app below:

Requirements:

For clarity, we'll be referring to our original activity from HW 2 as rgbActivity and our new activity created in HW 3 as hsvActivity.

1. Create a new activity with HSV SeekBars (there should be three for hue, saturation, value) and add a button on rgbActivity that opens hsvActivity, and add a button on hsvActivty that opens rgbActivity. The text labels for the SeekBars should look like the ones below:

2. Make sure that when the activity changes, both color square and sliders change values accordingly. For example, if the color in rgbActivity is #cdcdcd, then when the activity changes to hsvActivity, the color square and sliders should also represent #cdcdcd.

3. In hsvActivity, add a button below the Seekbars that finds your current location color. Make sure to change the Seekbars and the color square accordingly when the button is pressed. Use the code snippet below to create a custom color for your location:

<string name="locationString">#%1$s</string>

It may be the case that your emulator will return a null location! The best way to test this feature is to use a physical device; however, if you don't have one, you can hardcode the latitude to test the feature, and comment out this hardcoded value before you submit.

Location permissions (with EasyPermissions) require the following dependencies to be added to your gradle file!

implementation "com.vmadalin:easypermissions-ktx:1.0.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"

4. If the user denies location permission, display a Snackbar that states "Location permissions are not granted" and add a retry button in the Snackbar that requests for location permissions again (check this out for a tutorial on Snackbar):

5. Add a share button on rgbActivity that shares the color from the color square to other apps (through an ACTION_SEND). The share message should say “Check out this color: <color hex>”

Give yourself ample time to try and set up the Location permission request flow (come to office hours ASAP if you are stuck)! See 3.5 Permissions, requesting location permissions, and getting the last location.

Challenge Problems

These are optional challenge problems, and completing each successfully will earn you 1 extra point per problem. If you do attempt a challenge problem, make sure to include a readme.txt that states which problem(s) you've attempted!

Color Positioning System

  • Implement a two color palette where one color represents the longitude and one represents the latitude.

  • Modify the RGB sliders to represent “degrees, minutes, seconds” for precision accuracy.

  • Add a button to open Google Maps at that color’s location.

Dizzying Hues

  • Modify the HSV sliders to represent the X, Y, and Z readings from the gyroscope.

  • Add a switch to enable/disable continuous reading of gyroscope color.

  • (Note: You might need to test on physical device)

Preferential Treatment

  • Add the ability to save and retrieve a color from SharedPreferences.

  • Display saved colors in a list on a third activity.

References

For this assignment, you may need to figure out a few things on your own. Some classes that may be helpful for this assignment include:

For basic functionality:

  • Manifest

  • Intent

  • PackageManager

  • SnackBar

  • Location

  • Bundle

For challenge problems:

  • SensorManager

  • SharedPreferences

Last updated