Skip to content

Commit

Permalink
stupid android perms
Browse files Browse the repository at this point in the history
  • Loading branch information
ELY3M committed Oct 15, 2018
1 parent cccb270 commit f7ae391
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 17 additions & 4 deletions app/src/main/java/joshuatee/wx/StartupActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,29 @@ class StartupActivity : Activity(), ActivityCompat.OnRequestPermissionsResultCal
ObjectIntent(this, WXGLRadarActivity::class.java, WXGLRadarActivity.RID, arrayOf(rid1, nws1StateCurrent))
}


//location permission// this is needed!
val locationpermissionManager = PermissionManager.getInstance(this)
locationpermissionManager.checkPermissions(singleton(Manifest.permission.ACCESS_FINE_LOCATION), object : PermissionManager.PermissionRequestListener {
override fun onPermissionGranted() {
Log.i(TAG, "Location Permissions Granted")
}

override fun onPermissionDenied() {
Log.i(TAG, "Location Permissions Denied")
}
})

//storage permission so we can run checkfiles for custom icons//
val permissionManager = PermissionManager.getInstance(this)
permissionManager.checkPermissions(singleton(Manifest.permission.WRITE_EXTERNAL_STORAGE), object : PermissionManager.PermissionRequestListener {
val storagepermissionManager = PermissionManager.getInstance(this)
storagepermissionManager.checkPermissions(singleton(Manifest.permission.WRITE_EXTERNAL_STORAGE), object : PermissionManager.PermissionRequestListener {
override fun onPermissionGranted() {
Log.i(TAG, "Permissions Granted")
Log.i(TAG, "Storage Permissions Granted")
checkfiles()
}

override fun onPermissionDenied() {
Log.i(TAG, "Permissions Denied")
Log.i(TAG, "Storage Permissions Denied")
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ object SpotterNetworkPositionReport {


locationManager = context.getSystemService(Context.LOCATION_SERVICE) as (LocationManager)

//FIXME The selfcheck permissions is not working and crashing the app if the perms are off//
if (ContextCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED)
locationManager?.requestLocationUpdates(LocationManager.GPS_PROVIDER, 20000.toLong(), 30.toFloat(), locationListener)

Expand Down

0 comments on commit f7ae391

Please sign in to comment.