Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
a8f5b679
Commit
a8f5b679
authored
Jun 19, 2018
by
Evan W. Patton
Committed by
Jeffrey Schiller
Jun 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force draw compass on enable
Change-Id: I86ad3e3f63315d7b78765f59d1b5763b4f63104c
parent
2820e72a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
appinventor/components/src/com/google/appinventor/components/runtime/util/NativeOpenStreetMapController.java
...omponents/runtime/util/NativeOpenStreetMapController.java
+10
-2
appinventor/components/tests/com/google/appinventor/components/runtime/MapTest.java
...ts/com/google/appinventor/components/runtime/MapTest.java
+10
-0
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/util/NativeOpenStreetMapController.java
View file @
a8f5b679
...
...
@@ -62,6 +62,7 @@ import org.osmdroid.views.overlay.OverlayWithIWVisitor;
import
org.osmdroid.views.overlay.Polygon
;
import
org.osmdroid.views.overlay.Polyline
;
import
org.osmdroid.views.overlay.compass.CompassOverlay
;
import
org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider
;
import
org.osmdroid.views.overlay.gestures.RotationGestureOverlay
;
import
org.osmdroid.views.overlay.infowindow.OverlayInfoWindow
;
import
org.osmdroid.views.overlay.mylocation.IMyLocationConsumer
;
...
...
@@ -107,6 +108,7 @@ class NativeOpenStreetMapController implements MapController, MapListener {
private
OverlayInfoWindow
defaultInfoWindow
=
null
;
private
boolean
ready
=
false
;
private
ZoomControlView
zoomControls
=
null
;
private
float
lastAzimuth
=
Float
.
NaN
;
private
static
class
AppInventorLocationSensorAdapter
implements
IMyLocationProvider
,
LocationSensor
.
LocationSensorListener
{
...
...
@@ -383,8 +385,14 @@ class NativeOpenStreetMapController implements MapController, MapListener {
}
if
(
compass
!=
null
)
{
if
(
enabled
)
{
compass
.
enableCompass
();
if
(
compass
.
getOrientationProvider
()
!=
null
)
{
compass
.
enableCompass
();
}
else
{
compass
.
enableCompass
(
new
InternalCompassOrientationProvider
(
view
.
getContext
()));
}
compass
.
onOrientationChanged
(
lastAzimuth
,
null
);
}
else
{
lastAzimuth
=
compass
.
getOrientation
();
compass
.
disableCompass
();
}
}
...
...
@@ -392,7 +400,7 @@ class NativeOpenStreetMapController implements MapController, MapListener {
@Override
public
boolean
isCompassEnabled
()
{
return
compass
!=
null
&&
compass
.
isEnabled
();
return
compass
!=
null
&&
compass
.
is
Compass
Enabled
();
}
@Override
...
...
appinventor/components/tests/com/google/appinventor/components/runtime/MapTest.java
View file @
a8f5b679
...
...
@@ -5,6 +5,8 @@
package
com.google.appinventor.components.runtime
;
import
android.content.Context
;
import
android.hardware.Sensor
;
import
com.google.appinventor.components.runtime.shadows.ShadowAsynchUtil
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
com.google.appinventor.components.runtime.util.GeometryUtil
;
...
...
@@ -13,7 +15,9 @@ import org.easymock.EasyMock;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.osmdroid.util.GeoPoint
;
import
org.robolectric.RuntimeEnvironment
;
import
org.robolectric.shadow.api.Shadow
;
import
org.robolectric.shadows.ShadowSensorManager
;
import
org.robolectric.shadows.ShadowView
;
import
java.io.IOException
;
...
...
@@ -121,6 +125,12 @@ public class MapTest extends MapTestBase {
@Test
public
void
testShowCompass
()
{
/* We need to create a sensor for the orientation type, otherwise compass will fail to enable */
Context
context
=
RuntimeEnvironment
.
application
.
getApplicationContext
();
ShadowSensorManager
sensorManager
=
Shadow
.
extract
(
context
.
getSystemService
(
Context
.
SENSOR_SERVICE
));
Sensor
s
=
Shadow
.
newInstanceOf
(
Sensor
.
class
);
sensorManager
.
addSensor
(
Sensor
.
TYPE_ORIENTATION
,
s
);
/* end setup */
map
.
ShowCompass
(
true
);
assertTrue
(
map
.
ShowCompass
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment