Commit ccf69096 authored by Nick Whitelegg's avatar Nick Whitelegg
Browse files

Display warning if sensors are not supported (fixing issue #4)

parent ede33ced
hikar_new
\ No newline at end of file
hikar
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/hikar_new.iml" filepath="$PROJECT_DIR$/.idea/modules/hikar_new.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/app/hikar_new.app.iml" filepath="$PROJECT_DIR$/.idea/modules/app/hikar_new.app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
# Hikar 0.3.1
# Hikar 0.3.2
Hikar is an **augmented reality** app for Android (4.2+) which overlays footpaths
from OpenStreetMap on the device's camera feed and shows virtual signposts,
......
......@@ -13,8 +13,8 @@ android {
applicationId "freemap.hikar"
minSdkVersion 17
targetSdkVersion 28
versionCode 15
versionName "0.3.1"
versionCode 16
versionName "0.3.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
......
......@@ -74,11 +74,11 @@ class MainActivity : CoroutineActivity() {
// private var lastLat = 50.8839
// private var lastLon = -1.40883
//private var lastLat = 50.92892
// private var lastLon = -1.4131
// private var lastLat = 50.9416
// private var lastLon = -1.5029
// private var lastLat = 50.83
// private var lastLon = -1.5290
// private var lastLon = -1.4131
// private var lastLat = 50.9416
// private var lastLon = -1.5029
// private var lastLat = 50.83
// private var lastLon = -1.5290
//private var lastLat = 50.8899
private var field: GeomagneticField? = null
......@@ -115,6 +115,7 @@ class MainActivity : CoroutineActivity() {
private var lastNetworkErrorTime = 0L
private var routingMode = false
private var isSensorSupported: Boolean? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......@@ -182,15 +183,15 @@ class MainActivity : CoroutineActivity() {
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
var lang = prefs.getString("lang", "default") ?: ""
lang = if (lang == "default") "" else lang
lang = if (lang == "default") "" else lang
val distUnit = prefs.getString("distUnit", "km") ?: "km"
if(signpostMgr.locale != lang || signpostMgr.distUnit != distUnit) {
if (signpostMgr.locale != lang || signpostMgr.distUnit != distUnit) {
signpostMgr.locale = lang
signpostMgr.distUnit = distUnit
signpostMgr.clearSigns()
}
val zoomPref = (prefs.getString("zoomLevel", "13") ?: "13").toInt()
if(zoomPref != integrator.zoom) {
if (zoomPref != integrator.zoom) {
integrator.zoom = zoomPref
openGLView.renderer.clearOsmData()
signpostMgr.clearSigns()
......@@ -200,7 +201,14 @@ class MainActivity : CoroutineActivity() {
cameraInterface.getHfov()
// gl.onResume()
sensorInput.start()
if (isSensorSupported == true || isSensorSupported == null) {
isSensorSupported = sensorInput.start()
if (isSensorSupported == false) {
AlertDialog.Builder(this).setPositiveButton("OK", null)
.setMessage("Unfortunately Hikar will not work on your device as you do not have the required sensors (accelerometer, magnetometer)")
.show()
}
}
locationProcessor.startUpdates()
......@@ -281,7 +289,7 @@ class MainActivity : CoroutineActivity() {
R.id.about -> {
AlertDialog.Builder(this)
.setMessage("Hikar 0.3.1, (c) Nick Whitelegg 2013-19. Uses OpenStreetMap data, copyright OpenStreetMap contributors, licensed under the Open Database License. Uses former-Mapzen Terrarium elevation data, freely available via Amazon Web Services.")
.setMessage("Hikar 0.3.2, (c) Nick Whitelegg 2013-21. Uses OpenStreetMap data, copyright OpenStreetMap contributors, licensed under the Open Database License. Uses former-Mapzen Terrarium elevation data, freely available via Amazon Web Services.")
.setPositiveButton("OK", null).show()
}
}
......@@ -314,9 +322,10 @@ class MainActivity : CoroutineActivity() {
.setPositiveButton("OK", null).show()
} else {
withContext(Dispatchers.Default) {
route!!.filter { it.z < 0 || it.z == Double.MAX_VALUE }.forEach {
it.z = integrator.getHeight(it)
}
route!!.filter { it.z < 0 || it.z == Double.MAX_VALUE }
.forEach {
it.z = integrator.getHeight(it)
}
}
openGLView.renderer.setRoute(route!!)
hud.setRoutingLocation(poi!!.getValue("name"))
......@@ -345,7 +354,7 @@ class MainActivity : CoroutineActivity() {
}
private fun receiveLocation(loc: Location) {
setLocation(loc.longitude, loc.latitude, true)
setLocation(loc.longitude, loc.latitude, true)
}
private fun setLocation(lon: Double, lat: Double) {
......@@ -358,7 +367,12 @@ class MainActivity : CoroutineActivity() {
val p = Point(lon, lat)
if (field == null) {
field = GeomagneticField(lat.toFloat(), lon.toFloat(), p.z.toFloat(), System.currentTimeMillis())
field = GeomagneticField(
lat.toFloat(),
lon.toFloat(),
p.z.toFloat(),
System.currentTimeMillis()
)
}
......@@ -478,13 +492,18 @@ class MainActivity : CoroutineActivity() {
private fun receiveSensorInput(glR: FloatArray, bearingRadians: Float) {
val orientation = FloatArray(3)
val magNorth = field?.declination ?: 0.0f
val actualAdjustment = magNorth + (if (enableOrientationAdjustment) orientationAdjustment else 0.0f)
val actualAdjustment =
magNorth + (if (enableOrientationAdjustment) orientationAdjustment else 0.0f)
Matrix.rotateM(glR, 0, actualAdjustment, 0.0f, 1.0f, 0.0f)
SensorManager.getOrientation(glR, orientation)
openGLView.renderer.setOrientMtx(glR)
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
when (requestCode) {
......
......@@ -47,9 +47,9 @@ class SensorInput(private val receiver: (FloatArray, Float)->Unit) : SensorEvent
magneticField = sMgr?.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD)
if (accelerometer != null && magneticField != null) {
sMgr?.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_UI)
sMgr?.registerListener(this, magneticField, SensorManager.SENSOR_DELAY_UI)
return true
val accel = sMgr?.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_UI) ?: false
val magField = sMgr?.registerListener(this, magneticField, SensorManager.SENSOR_DELAY_UI) ?: false
return accel && magField
}
return false
}
......
Hikar 0.3.2 (version code 16)
-----------------------------
- added warning if device does not have the required sensors (accelerometer, magnetometer) - fixing issue #4.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment