diff --git a/app/build.gradle b/app/build.gradle index 2e7549fb1..277bc92b4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -286,6 +286,8 @@ dependencies { implementation 'com.github.tobiaskaminsky:ImagePicker:extraFile-SNAPSHOT' implementation 'com.elyeproj.libraries:loaderviewlibrary:2.0.0' + implementation 'org.osmdroid:osmdroid-android:6.1.10' + testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-core:3.11.0' testImplementation "org.powermock:powermock-core:${powermockVersion}" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b92c45f31..c5b1af412 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -70,6 +70,8 @@ + + = Build.VERSION_CODES.M) { + if (PermissionChecker.checkSelfPermission( + context!!, + Manifest.permission.ACCESS_FINE_LOCATION + ) == PermissionChecker.PERMISSION_GRANTED + ) { + Log.d(TAG, "Permission is granted") + return true + } else { + Log.d(TAG, "Permission is revoked") + return false + } + } else { //permission is automatically granted on sdk<23 upon installation + Log.d(TAG, "Permission is granted") + return true + } + } + + private fun requestFineLocationPermission() { + requestPermissions( + arrayOf( + Manifest.permission.ACCESS_FINE_LOCATION + ), + REQUEST_PERMISSIONS_REQUEST_CODE + ) + } + + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { + if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE && grantResults.size > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + drawMap() + } else { + Toast.makeText(context, "location permission required!", Toast.LENGTH_LONG).show() + } + } + + companion object { + private val TAG = "LocationController" + private val REQUEST_PERMISSIONS_REQUEST_CODE = 1; + } +} diff --git a/app/src/main/res/drawable/ic_baseline_gps_fixed_24.xml b/app/src/main/res/drawable/ic_baseline_gps_fixed_24.xml new file mode 100644 index 000000000..b05033003 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_gps_fixed_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/controller_location.xml b/app/src/main/res/layout/controller_location.xml new file mode 100644 index 000000000..014589912 --- /dev/null +++ b/app/src/main/res/layout/controller_location.xml @@ -0,0 +1,24 @@ + + + + + + + + + \ No newline at end of file