From f7ae391d83c68de350d21396d3fa4a93bea4003e Mon Sep 17 00:00:00 2001 From: ELY M Date: Mon, 15 Oct 2018 00:44:02 -0500 Subject: [PATCH] stupid android perms --- .../main/java/joshuatee/wx/StartupActivity.kt | 21 +++++++++++++++---- .../wx/radar/SpotterNetworkPositionReport.kt | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/joshuatee/wx/StartupActivity.kt b/app/src/main/java/joshuatee/wx/StartupActivity.kt index ba91ee70..6195f61a 100644 --- a/app/src/main/java/joshuatee/wx/StartupActivity.kt +++ b/app/src/main/java/joshuatee/wx/StartupActivity.kt @@ -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") } }) diff --git a/app/src/main/java/joshuatee/wx/radar/SpotterNetworkPositionReport.kt b/app/src/main/java/joshuatee/wx/radar/SpotterNetworkPositionReport.kt index c795b42a..0da6207a 100644 --- a/app/src/main/java/joshuatee/wx/radar/SpotterNetworkPositionReport.kt +++ b/app/src/main/java/joshuatee/wx/radar/SpotterNetworkPositionReport.kt @@ -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)