request location permission for twilight manager (day/night mode)

This commit is contained in:
David Luhmer 2019-04-29 19:43:30 -04:00
parent 9c856b4f56
commit 959958e857
3 changed files with 21 additions and 1 deletions

View file

@ -19,7 +19,10 @@
<!-- <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" /> -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /> -->
<!-- Required for TwilightManager -->
<!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".NewsReaderApplication"
android:allowBackup="true"

View file

@ -269,6 +269,20 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
if (tabletSize) {
showTapLogoToSyncShowcaseView();
}
if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
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}, 139);
})
.create()
.show();
}
}
@Override

View file

@ -28,6 +28,9 @@
<string name="img_view_thumbnail" translatable="false">Thumbnail</string>
<string name="tv_showing_cached_version">Showing cached version</string>
<string name="permission_req_location_twilight_title">Automated Light/Dark Theme</string>
<string name="permission_req_location_twilight_text">In order to automatically switch between the light and dark theme, it is required to provide the devices location in order to determine the time for sunrise and sunset.</string>
<!-- Action Bar Items -->
<string name="action_starred">Starred</string>
<string name="action_read">Read</string>