diff options
author | Scott Jackson <daneren2005@gmail.com> | 2016-10-21 18:16:12 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2016-10-21 18:16:12 -0700 |
commit | bb248548d25a14d695b48051d8df79422c398878 (patch) | |
tree | 95444d6ef0f0c4bc79628812e16ec93afe57a087 /app | |
parent | b7e728dc0788a23af2eecb9f5870c3c612aa50a7 (diff) | |
download | dsub-bb248548d25a14d695b48051d8df79422c398878.tar.gz dsub-bb248548d25a14d695b48051d8df79422c398878.tar.bz2 dsub-bb248548d25a14d695b48051d8df79422c398878.zip |
Ask for location permissions in support for the day/night theme
Diffstat (limited to 'app')
3 files changed, 15 insertions, 1 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 65305cbd..2cb24272 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,6 +23,7 @@ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-feature android:name="android.hardware.touchscreen" android:required="false" /> <uses-feature android:name="android.hardware.bluetooth" android:required="false" /> 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 dcf966a8..3b533fae 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -95,7 +95,8 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte protected static boolean actionbarColored; private static final int MENU_GROUP_SERVER = 10; private static final int MENU_ITEM_SERVER_BASE = 100; - private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1; + public static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1; + public static final int PERMISSIONS_REQUEST_LOCATION = 2; private final List<Runnable> afterServiceAvailable = new ArrayList<>(); private boolean drawerIdle = true; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java index d5ba25f5..584a205a 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java @@ -15,12 +15,14 @@ package github.daneren2005.dsub.fragments; +import android.Manifest; import android.accounts.Account; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; import android.preference.CheckBoxPreference; @@ -29,6 +31,8 @@ import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.text.InputType; import android.util.Log; import android.view.LayoutInflater; @@ -47,6 +51,7 @@ import java.util.LinkedHashMap; import java.util.Map; import github.daneren2005.dsub.R; +import github.daneren2005.dsub.activity.SubsonicActivity; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.HeadphoneListenerService; import github.daneren2005.dsub.service.MusicService; @@ -188,6 +193,13 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared } else { context.stopService(serviceIntent); } + } else if(Constants.PREFERENCES_KEY_THEME.equals(key)) { + String value = sharedPreferences.getString(key, null); + if("day/night".equals(value) || "day/black".equals(value)) { + if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(context, new String[]{ Manifest.permission.ACCESS_COARSE_LOCATION }, SubsonicActivity.PERMISSIONS_REQUEST_LOCATION); + } + } } scheduleBackup(); |