Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSE340 Sensing and Location
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cse340
exercises
CSE340 Sensing and Location
Commits
faa67d43
Commit
faa67d43
authored
2 years ago
by
Lauren Bricker
Browse files
Options
Downloads
Patches
Plain Diff
prepping for adding mapbox as an activity
parent
c199f891
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Mapbox sync
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+72
-3
72 additions, 3 deletions
README.md
app/build.gradle
+1
-1
1 addition, 1 deletion
app/build.gradle
build.gradle
+1
-6
1 addition, 6 deletions
build.gradle
gradle/wrapper/gradle-wrapper.properties
+1
-1
1 addition, 1 deletion
gradle/wrapper/gradle-wrapper.properties
with
75 additions
and
11 deletions
README.md
+
72
−
3
View file @
faa67d43
...
...
@@ -2,8 +2,77 @@
Experimenting with a Android Sensing and Location.
Things you can do with this:
## SensorActivity Exercise
-
Make the Gyroscope work
-
Add another sensor to
`SensorActivity`
-
Add more data to the
`LocationActivity`
screen
-
Store state of the on/off switches in
`SharedPreferences`
-
Add a map with
[
Mapbox
](
https://www.mapbox.com/
)
\ No newline at end of file
## LocationActivity Exercise
About:
-
Mapbox is a provider of custom online maps and location services.
-
This project uses the Mapbox Android SDK to display an interactive map.
-
Once the user grants location permissions, the map can be re-centered
by the "Find My Location Button" to the device's coordinates.
Precise Location is required to display the long/lat.
-
Noteworthy files to look at:
-
location_layout.xml > <com.mapbox.maps.MapView...
-
LocationActivity.java > customizeMapAppearance()
-
Module Level build.gradle > line 37 (declares mapbox dependency)
-
Mapbox SDK requires a public key (for inflating MapView XML) and secret key (for Mapbox Maven
dependency).
-
Sources consulted:
https://docs.mapbox.com/android/maps/guides/install/
https://stackoverflow.com/questions/38501402/hide-credentials-for-all-projects-in-build-gradle
https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#declare_properties_in_gradle_properties_file
TODOs:
1.
Configure Mapbox Credentials:
a. Register for a free account on Mapbox.
b. Note your default public access key from https://account.mapbox.com/access-tokens/,
then create a string resource value (app/src/main/res/values > create new XML file with a name
of your choice). In that file, copy and paste your public key in the new file after
declaring
<string
name=
"mapbox_access_token"
>
... Make sure to not include it in git tracking.
c. Go back to https://account.mapbox.com/access-tokens/ and create another key. Scopes should
include all Public Scopes and DOWNLOADS:READ. Note the secret key after it is created.
d. Create a local file at $HOME/.gradle, called 'gradle.properties'. Put your secret key there
in the format: MAPBOX_SECRET_TOKEN=YOUR_SECRET_TOKEN and save the file. 'MAPBOX_SECRET_TOKEN'
is referred to in settings.gradle for downloading the Mapbox dependency.
-
Note: You should be able to see gradle.properties (Global Properties on your left sidebar now).
-
To find where Gradle is installed, go to:
-
Mac: Android Studio > Preferences > Build Execution Deployment (~/.gradle)
-
Windows: File > Settings > Build Execution Deployment (C:
\U
sers
\<
username>
\.
gradle)
2.
Code: Show the location on the Map.
a. Insert this XML object
<com.mapbox.maps.MapView
android:id="@+id/map_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/actual_location"
app:mapbox_cameraTargetLat="40.7128"
app:mapbox_cameraTargetLng="-74.0060"
app:mapbox_cameraZoom="8.0">
</com.mapbox.maps.MapView>
inside location_layout.xml. This will be the map displayed on the screen.
b. Use the location grabbed from the user's device and display it on the map
when the user presses the "Find My Location" button.
c. Handle the case where the user did not turn on location permissions but tries
to click the "Find My Location" button.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/build.gradle
+
1
−
1
View file @
faa67d43
...
...
@@ -9,7 +9,7 @@ android {
minSdkVersion
26
targetSdkVersion
31
buildToolsVersion
"
29
.0.
0
"
buildToolsVersion
"
30
.0.
3
"
versionCode
1
versionName
"1.0"
}
...
...
This diff is collapsed.
Click to expand it.
build.gradle
+
1
−
6
View file @
faa67d43
...
...
@@ -5,7 +5,7 @@ buildscript {
mavenCentral
()
}
dependencies
{
classpath
'com.android.tools.build:gradle:
3.6.4
'
classpath
'com.android.tools.build:gradle:
7.1.3
'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
...
...
@@ -17,11 +17,6 @@ allprojects {
mavenCentral
()
}
// gradle.projectsEvaluated{
// tasks.withType(JavaCompile){
// options.compilerArgs << "-Xlint:deprecation"
// }
// }
}
task
clean
(
type:
Delete
)
{
...
...
This diff is collapsed.
Click to expand it.
gradle/wrapper/gradle-wrapper.properties
+
1
−
1
View file @
faa67d43
#Mon Oct 04 21:36:06 PDT 2021
distributionBase
=
GRADLE_USER_HOME
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
5.6.4
-bin.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
7.2
-bin.zip
distributionPath
=
wrapper/dists
zipStorePath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment