diff --git a/News-Android-App/build.gradle b/News-Android-App/build.gradle index 8fb1c6a0..180c27cb 100644 --- a/News-Android-App/build.gradle +++ b/News-Android-App/build.gradle @@ -115,7 +115,7 @@ repositories { jcenter() maven { url "https://jitpack.io" } maven { url 'https://guardian.github.com/maven/repo-releases' } //needed for com.gu:option:1.3 in Android-DirectoryChooser - maven { url "https://dl.bintray.com/lukaville/maven" } //Needed for com.nbsp:library:1.02 in Material File Picker + maven { url "https://dl.bintray.com/lukaville/maven" } //Needed for com.nbsp:library:1.8 in Material File Picker } final DAGGER_VERSION = '2.22.1' diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java index 63ffde85..4a625ed5 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java @@ -271,8 +271,14 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements } - if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(this, new String[]{ACCESS_FINE_LOCATION}, REQUEST_CODE_PERMISSION_LOCATION); + // In case automatic theme selection based on time is selected, check if location permission + // for twilight manager is given.. otherwise request it + if(ThemeChooser.isAutoThemeSelectionEnabled() && ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions( + this, + new String[]{ ACCESS_FINE_LOCATION }, + REQUEST_CODE_PERMISSION_LOCATION + ); } } @@ -993,7 +999,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements builder.setTitle(getString(R.string.permission_req_location_twilight_title)) .setMessage(getString(R.string.permission_req_location_twilight_text)) .setPositiveButton(android.R.string.ok, (dialog, id) -> { - //ActivityCompat.requestPermissions(this, new String[]{ACCESS_COARSE_LOCATION}, 1349); ActivityCompat.requestPermissions(this, new String[]{ACCESS_FINE_LOCATION}, REQUEST_CODE_PERMISSION_LOCATION); }) .setNegativeButton(android.R.string.cancel, (dialog, id) -> {}) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/ThemeChooser.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/ThemeChooser.java index 9ff7fe00..bca65568 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/ThemeChooser.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/ThemeChooser.java @@ -107,6 +107,15 @@ public class ThemeChooser { */ } + /** + * Returns true if automatic theme selection based on Twilight Manager is enabled. + * Otherwise it'll return false + */ + public static boolean isAutoThemeSelectionEnabled() { + int selectedTheme = getSelectedThemeFromPreferences(false); + return selectedTheme == 0; // 0 => Auto (Light / Dark) + } + // Check if the currently loaded theme is different from the one set in the settings, or if OLED mode changed public static boolean themeRequiresRestartOfUI() { boolean themeChanged = !mSelectedThemeFromPreferences.equals(getSelectedThemeFromPreferences(true));