From 28cf757952f789896bf8e8b5174947b03942f792 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 12 Oct 2020 20:56:59 -0700 Subject: Request location permissions on every startup if not given --- .../github/daneren2005/dsub/activity/SubsonicActivity.java | 13 ++++++++++++- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java index 3b6935eb..d475be7b 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -18,6 +18,7 @@ */ package github.daneren2005.dsub.activity; +import android.Manifest; import android.app.UiModeManager; import android.content.Context; import android.content.DialogInterface; @@ -184,6 +185,17 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte if (ContextCompat.checkSelfPermission(this, permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{ permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); } + + SharedPreferences prefs = Util.getPreferences(this); + int instance = prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1); + String expectedSSID = prefs.getString(Constants.PREFERENCES_KEY_SERVER_LOCAL_NETWORK_SSID + instance, ""); + if(!expectedSSID.isEmpty()) { + String currentSSID = Util.getSSID(this); + + if(currentSSID == "" && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, SubsonicActivity.PERMISSIONS_REQUEST_LOCATION); + } + } } @Override @@ -204,7 +216,6 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte } else { Util.toast(this, R.string.permission_location_failed); - finish(); } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2dcee2d6..87ebbe07 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -669,7 +669,7 @@ Home Page DSub cannot function without the ability to write to storage - This apps uses location data to get the WIFI SSID when the app is in use. No location data is collected. + This apps uses location data to get the WIFI SSID to match against your local network settings. To get rid of this message, change the local network SSID to blank. No songs -- cgit v1.2.3