Package com.cmput301w23t09.qrhunter.map
Class LocationHandler
- java.lang.Object
-
- com.cmput301w23t09.qrhunter.map.LocationHandler
-
public class LocationHandler extends java.lang.Object
Handles location permissions and retrieving the location of the player's device. Used to set the location of a QRCode.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]
LOCATION_PERMISSIONS
static int
REQUEST_CODE_PERMISSIONS
-
Constructor Summary
Constructors Constructor Description LocationHandler(androidx.fragment.app.Fragment fragment)
Creates a new LocationHandler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLocation(QRCode qrCode)
Adds current location to the list of QR Codes.boolean
locationPermissionsGranted()
Checks if at least one of the location permissions was granted.void
removeLastAddedLocation(QRCode qrCode)
Removes the most-recently added location from the QR codevoid
setQrToLastLocation(QRCode qrCode)
Sets the provided QRCode to the device's last known location
-
-
-
Field Detail
-
REQUEST_CODE_PERMISSIONS
public static final int REQUEST_CODE_PERMISSIONS
- See Also:
- Constant Field Values
-
LOCATION_PERMISSIONS
public static final java.lang.String[] LOCATION_PERMISSIONS
-
-
Constructor Detail
-
LocationHandler
public LocationHandler(androidx.fragment.app.Fragment fragment)
Creates a new LocationHandler- Parameters:
fragment
- The fragment that will use the user's location- See Also:
QRCodeFragment
-
-
Method Detail
-
setQrToLastLocation
public void setQrToLastLocation(QRCode qrCode)
Sets the provided QRCode to the device's last known location- Parameters:
qrCode
- The QRCode to set the location of.
-
addLocation
public void addLocation(QRCode qrCode)
Adds current location to the list of QR Codes.- Parameters:
qrCode
- The QRCode to add current location to.
-
removeLastAddedLocation
public void removeLastAddedLocation(QRCode qrCode)
Removes the most-recently added location from the QR code- Parameters:
qrCode
- The QRCode to remove location from
-
locationPermissionsGranted
public boolean locationPermissionsGranted()
Checks if at least one of the location permissions was granted.- Returns:
- True if the user has granted access to either FINE or COARSE location, False otherwise.
-
-